tcp_socket.h
Go to the documentation of this file.
00001 00043 #ifndef NET_TCP_SOCKET_H 00044 #define NET_TCP_SOCKET_H 00045 00046 #include <cfg/macros.h> 00047 00048 #include <io/kfile.h> 00049 00050 #include <lwip/netif.h> 00051 #include <lwip/ip_addr.h> 00052 00056 typedef void (*tcphandler_t)(KFile *fd); 00057 00058 typedef struct TcpSocket 00059 { 00060 KFile fd; 00061 struct netconn *sock; 00062 struct netbuf *rx_buf_conn; 00063 size_t remaning_data_len; 00064 00065 struct ip_addr *local_addr; 00066 struct ip_addr *remote_addr; 00067 uint16_t port; 00068 00069 int error; 00070 00071 struct netconn *server_sock; 00072 tcphandler_t handler; 00073 } TcpSocket; 00074 00075 #define KFT_TCPSOCKET MAKE_ID('T', 'S', 'C', 'K') 00076 00077 INLINE TcpSocket *TCPSOCKET_CAST(KFile *fd) 00078 { 00079 ASSERT(fd->_type == KFT_TCPSOCKET); 00080 return (TcpSocket *)fd; 00081 } 00082 00083 void tcpsocket_init(TcpSocket *socket, struct ip_addr *local_addr, struct ip_addr *remote_addr, uint16_t port); 00084 00085 void tcpsocket_serverPoll(KFile *fd); 00086 void tcpsocket_serverInit(TcpSocket *socket, struct ip_addr *local_addr, struct ip_addr *remote_addr, uint16_t port, tcphandler_t handler); 00087 00088 #endif /* NET_TCP_SOCKET_H */
![(please configure the [header_logo] section in trac.ini)](/chrome/site/bertos_logo.png)