FANDOM


netconn_connectEdit

err_t netconn_connect ( struct netconn * aNetConn, 
                        ip_addr_t * aAddr, u16_t aPport );
  • in aNetConn : netconn structure received by netconn_new or netconn_accept.
  • in aAddr : the IP address of the remote server to connect to
  • in aPort : the port of the remote server to connect to

Attempt to establish a connection between the local client and a remote server.

Example of a client:


struct netconn *xNetConn = NULL;

struct ip_addr local_ip; 
struct ip_addr remote_ip; 
int rc1, rc2; 
 
xNetConn = netconn_new ( NETCONN_TCP ); 
 
if ( xNetConn == NULL ) { 
 
 /* No memory for new connection? */
 continue;
}

local_ip.addr = <get IP of this device>

rc1 = netconn_bind ( xNetConn, &local_ip, 0 ); 
 
remote_ip.addr = xRemoteIp; // static or by netconn_gethostbyname ()
rc2 = netconn_connect ( xNetConn, &remote_ip, cClientPort ); 
 
if ( rc1 != ERR_OK || rc2 != ERR_OK )
{

  netconn_delete ( xNetConn );
 continue;
}

(last changed: August 2, 2011)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.