* @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 */
| 374 | * @return ERR_OK if connected, return value of tcp_/udp_/raw_connect otherwise |
| 375 | */ |
| 376 | err_t |
| 377 | netconn_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 |