Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <lwip/api.h>
- #include <lwip/netif.h>
- #define DIE(assertion, call_description) \
- do { \
- if (assertion) { \
- fprintf(stderr, "(%s, %d): %s\n", \
- __FILE__, __LINE__, call_description); \
- return; \
- } \
- } while(0)
- void my_app(void *args){
- struct netconn *netConn;
- struct ip_addr local_ip, remote_ip;
- int rc;
- netConn = netconn_new(NETCONN_TCP);
- DIE(!netConn, "netconn_new");
- local_ip.addr = htonl(0x0a00020f);
- rc = netconn_bind(netConn, &local_ip, 0);
- DIE(rc != ERR_OK, "netconn_bind");
- remote_ip.addr = htonl(0x0a00020a);
- rc = netconn_connect(netConn, &remote_ip, 13);
- DIE(rc != ERR_OK, "netconn_connect");
- printf("Conectare cu succes!\n");
- }
- int main(int argc, char *argv[]){
- sys_thread_new("client", my_app, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
- pause();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement