MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / netconn_connect

Function netconn_connect

components/net/lwip/lwip-2.1.2/src/api/api_lib.c:376–399  ·  view source on GitHub ↗

* @ingroup netconn_common * Connect a netconn to a specific remote IP address and port. * * @param conn the netconn to connect * @param addr the remote IP address to connect to * @param port the remote port to connect to (no used for RAW) * @return ERR_OK if connected, return value of tcp_/udp_/raw_connect otherwise */

Source from the content-addressed store, hash-verified

374 * @return ERR_OK if connected, return value of tcp_/udp_/raw_connect otherwise
375 */
376err_t
377netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port)
378{
379 API_MSG_VAR_DECLARE(msg);
380 err_t err;
381
382 LWIP_ERROR("netconn_connect: invalid conn", (conn != NULL), return ERR_ARG;);
383
384#if LWIP_IPV4
385 /* Don't propagate NULL pointer (IP_ADDR_ANY alias) to subsequent functions */
386 if (addr == NULL) {
387 addr = IP4_ADDR_ANY;
388 }
389#endif /* LWIP_IPV4 */
390
391 API_MSG_VAR_ALLOC(msg);
392 API_MSG_VAR_REF(msg).conn = conn;
393 API_MSG_VAR_REF(msg).msg.bc.ipaddr = API_MSG_VAR_REF(addr);
394 API_MSG_VAR_REF(msg).msg.bc.port = port;
395 err = netconn_apimsg(lwip_netconn_do_connect, &API_MSG_VAR_REF(msg));
396 API_MSG_VAR_FREE(msg);
397
398 return err;
399}
400
401/**
402 * @ingroup netconn_udp

Callers 3

lwip_connectFunction · 0.70
drv_ethernet.cFile · 0.50
udpecho_entryFunction · 0.50

Calls 1

netconn_apimsgFunction · 0.70

Tested by 1

udpecho_entryFunction · 0.40