* Bind a netconn to a specific local IP address and port. * Binding one netconn twice might not always be checked correctly! * * @param conn the netconn to bind * @param addr the local IP address to bind the netconn to (use IP_ADDR_ANY * to bind to all addresses) * @param port the local port to bind the netconn to (not used for RAW) * @return ERR_OK if bound, any other err_t on
| 163 | * @return ERR_OK if bound, any other err_t on failure |
| 164 | */ |
| 165 | err_t |
| 166 | netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port) |
| 167 | { |
| 168 | struct api_msg msg; |
| 169 | err_t err; |
| 170 | |
| 171 | LWIP_ERROR("netconn_bind: invalid conn", (conn != NULL), return ERR_ARG;); |
| 172 | |
| 173 | msg.function = do_bind; |
| 174 | msg.msg.conn = conn; |
| 175 | msg.msg.msg.bc.ipaddr = addr; |
| 176 | msg.msg.msg.bc.port = port; |
| 177 | err = TCPIP_APIMSG(&msg); |
| 178 | |
| 179 | NETCONN_SET_SAFE_ERR(conn, err); |
| 180 | return err; |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * Connect a netconn to a specific remote IP address and port. |