87 |
{ |
{ |
88 |
struct lwip_socket *sock; |
struct lwip_socket *sock; |
89 |
struct netconn *newconn; |
struct netconn *newconn; |
90 |
struct ip_addr *naddr; |
struct ip_addr naddr; |
91 |
u16_t port; |
u16_t port; |
92 |
int newsock; |
int newsock; |
93 |
|
|
101 |
/* get the IP address and port of the remote host */ |
/* get the IP address and port of the remote host */ |
102 |
netconn_peer(newconn, &naddr, &port); |
netconn_peer(newconn, &naddr, &port); |
103 |
|
|
104 |
((struct sockaddr_in *)addr)->sin_addr.s_addr = naddr->addr; |
((struct sockaddr_in *)addr)->sin_addr.s_addr = naddr.addr; |
105 |
((struct sockaddr_in *)addr)->sin_port = port; |
((struct sockaddr_in *)addr)->sin_port = port; |
106 |
|
|
107 |
newsock = alloc_socket(newconn); |
newsock = alloc_socket(newconn); |
345 |
struct sockaddr *to, int tolen) |
struct sockaddr *to, int tolen) |
346 |
{ |
{ |
347 |
struct lwip_socket *sock; |
struct lwip_socket *sock; |
348 |
struct ip_addr remote_addr, *addr; |
struct ip_addr remote_addr, addr; |
349 |
u16_t remote_port, port; |
u16_t remote_port, port; |
350 |
int ret,connected; |
int ret,connected; |
351 |
|
|
366 |
/* reset the remote address and port number |
/* reset the remote address and port number |
367 |
of the connection */ |
of the connection */ |
368 |
if (connected) |
if (connected) |
369 |
netconn_connect(sock->conn, addr, port); |
netconn_connect(sock->conn, &addr, port); |
370 |
else |
else |
371 |
netconn_disconnect(sock->conn); |
netconn_disconnect(sock->conn); |
372 |
return ret; |
return ret; |