Lines Matching refs:conn
70 struct netconn *conn;
73 conn = netconn_alloc(t, callback);
74 if (conn != NULL) {
77 msg.msg.conn = conn;
79 LWIP_ASSERT("freeing conn without freeing pcb", conn->pcb.tcp == NULL);
80 LWIP_ASSERT("conn has no op_completed", sys_sem_valid(&conn->op_completed));
81 LWIP_ASSERT("conn has no recvmbox", sys_mbox_valid(&conn->recvmbox));
83 LWIP_ASSERT("conn->acceptmbox shouldn't exist", !sys_mbox_valid(&conn->acceptmbox));
85 sys_sem_free(&conn->op_completed);
86 sys_mbox_free(&conn->recvmbox);
87 memp_free(MEMP_NETCONN, conn);
91 return conn;
99 * @param conn the netconn to delete
103 netconn_delete(struct netconn *conn)
107 /* No ASSERT here because possible to get a (conn == NULL) if we got an accept error */
108 if (conn == NULL) {
113 msg.msg.conn = conn;
116 netconn_free(conn);
127 * @param conn the netconn to query
135 netconn_getaddr(struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local)
140 LWIP_ERROR("netconn_getaddr: invalid conn", (conn != NULL), return ERR_ARG;);
145 msg.msg.conn = conn;
151 NETCONN_SET_SAFE_ERR(conn, err);
159 * @param conn the netconn to bind
166 netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port)
171 LWIP_ERROR("netconn_bind: invalid conn", (conn != NULL), return ERR_ARG;);
174 msg.msg.conn = conn;
179 NETCONN_SET_SAFE_ERR(conn, err);
186 * @param conn the netconn to connect
192 netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port)
197 LWIP_ERROR("netconn_connect: invalid conn", (conn != NULL), return ERR_ARG;);
200 msg.msg.conn = conn;
206 NETCONN_SET_SAFE_ERR(conn, err);
213 * @param conn the netconn to disconnect
217 netconn_disconnect(struct netconn *conn)
222 LWIP_ERROR("netconn_disconnect: invalid conn", (conn != NULL), return ERR_ARG;);
225 msg.msg.conn = conn;
228 NETCONN_SET_SAFE_ERR(conn, err);
235 * @param conn the tcp netconn to set to listen mode
241 netconn_listen_with_backlog(struct netconn *conn, u8_t backlog)
250 LWIP_ERROR("netconn_listen: invalid conn", (conn != NULL), return ERR_ARG;);
253 msg.msg.conn = conn;
259 NETCONN_SET_SAFE_ERR(conn, err);
262 LWIP_UNUSED_ARG(conn);
271 * @param conn the TCP listen netconn
277 netconn_accept(struct netconn *conn, struct netconn **new_conn)
288 LWIP_ERROR("netconn_accept: invalid conn", (conn != NULL), return ERR_ARG;);
289 LWIP_ERROR("netconn_accept: invalid acceptmbox", sys_mbox_valid(&conn->acceptmbox), return ERR_ARG;);
291 err = conn->last_err;
299 if (sys_arch_mbox_fetch(&conn->acceptmbox, (void **)&newconn, conn->recv_timeout) == SYS_ARCH_TIMEOUT) {
300 NETCONN_SET_SAFE_ERR(conn, ERR_TIMEOUT);
304 sys_arch_mbox_fetch(&conn->acceptmbox, (void **)&newconn, 0);
307 API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0);
311 NETCONN_SET_SAFE_ERR(conn, ERR_ABRT);
317 msg.msg.conn = conn;
323 /* don't set conn->last_err: it's only ERR_OK, anyway */
326 LWIP_UNUSED_ARG(conn);
336 * @param conn the netconn from which to receive data
342 netconn_recv_data(struct netconn *conn, void **new_buf)
353 LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL), return ERR_ARG;);
354 LWIP_ERROR("netconn_accept: invalid recvmbox", sys_mbox_valid(&conn->recvmbox), return ERR_CONN;);
356 err = conn->last_err;
366 if (sys_arch_mbox_fetch(&conn->recvmbox, &buf, conn->recv_timeout) == SYS_ARCH_TIMEOUT) {
367 NETCONN_SET_SAFE_ERR(conn, ERR_TIMEOUT);
371 sys_arch_mbox_fetch(&conn->recvmbox, &buf, 0);
376 if (conn->type == NETCONN_TCP)
379 if (!netconn_get_noautorecved(conn) || (buf == NULL)) {
384 msg.msg.conn = conn;
396 API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0);
398 NETCONN_SET_SAFE_ERR(conn, ERR_CLSD);
415 SYS_ARCH_DEC(conn->recv_avail, len);
418 API_EVENT(conn, NETCONN_EVT_RCVMINUS, len);
423 /* don't set conn->last_err: it's only ERR_OK, anyway */
430 * @param conn the netconn from which to receive data
434 * ERR_ARG if conn is not a TCP netconn
437 netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf)
439 LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL) &&
440 netconn_type(conn) == NETCONN_TCP, return ERR_ARG;);
442 return netconn_recv_data(conn, (void **)new_buf);
448 * @param conn the netconn from which to receive data
454 netconn_recv(struct netconn *conn, struct netbuf **new_buf)
463 LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL), return ERR_ARG;);
464 LWIP_ERROR("netconn_accept: invalid recvmbox", sys_mbox_valid(&conn->recvmbox), return ERR_CONN;);
468 if (conn->type == NETCONN_TCP)
476 NETCONN_SET_SAFE_ERR(conn, ERR_MEM);
480 err = netconn_recv_data(conn, (void **)&p);
492 /* don't set conn->last_err: it's only ERR_OK, anyway */
501 return netconn_recv_data(conn, (void **)new_buf);
511 * Can only be used when calling netconn_set_noautorecved(conn, 1) before.
513 * @param conn the netconn for which to update the receive window
517 netconn_recved(struct netconn *conn, u32_t length)
520 if ((conn != NULL) && (conn->type == NETCONN_TCP) &&
521 (netconn_get_noautorecved(conn))) {
527 msg.msg.conn = conn;
533 LWIP_UNUSED_ARG(conn);
542 * @param conn the netconn over which to send data
549 netconn_sendto(struct netconn *conn, struct netbuf *buf, ip_addr_t *addr, u16_t port)
554 return netconn_send(conn, buf);
562 * @param conn the UDP or RAW netconn over which to send data
567 netconn_send(struct netconn *conn, struct netbuf *buf)
572 LWIP_ERROR("netconn_send: invalid conn", (conn != NULL), return ERR_ARG;);
576 msg.msg.conn = conn;
580 NETCONN_SET_SAFE_ERR(conn, err);
587 * @param conn the TCP netconn over which to send data
598 netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size,
605 LWIP_ERROR("netconn_write: invalid conn", (conn != NULL), return ERR_ARG;);
606 LWIP_ERROR("netconn_write: invalid conn->type", (conn->type == NETCONN_TCP), return ERR_VAL;);
610 dontblock = netconn_is_nonblocking(conn) || (apiflags & NETCONN_DONTBLOCK);
619 msg.msg.conn = conn;
624 if (conn->send_timeout != 0) {
626 sys_now() + conn->send_timeout */
640 || (conn->send_timeout != 0)
651 NETCONN_SET_SAFE_ERR(conn, err);
658 * @param conn the TCP netconn to close or shutdown
663 netconn_close_shutdown(struct netconn *conn, u8_t how)
668 LWIP_ERROR("netconn_close: invalid conn", (conn != NULL), return ERR_ARG;);
671 msg.msg.conn = conn;
678 NETCONN_SET_SAFE_ERR(conn, err);
685 * @param conn the TCP netconn to close
689 netconn_close(struct netconn *conn)
692 return netconn_close_shutdown(conn, NETCONN_SHUT_RDWR);
698 * @param conn the TCP netconn to shut down
702 netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx)
704 return netconn_close_shutdown(conn, (shut_rx ? NETCONN_SHUT_RD : 0) | (shut_tx ? NETCONN_SHUT_WR : 0));
711 * @param conn the UDP netconn for which to change multicast addresses
719 netconn_join_leave_group(struct netconn *conn,
727 LWIP_ERROR("netconn_join_leave_group: invalid conn", (conn != NULL), return ERR_ARG;);
730 msg.msg.conn = conn;
736 NETCONN_SET_SAFE_ERR(conn, err);