PolarSSL v1.3.7
net.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_NET_H
28 #define POLARSSL_NET_H
29 
30 #include <string.h>
31 
32 #define POLARSSL_ERR_NET_UNKNOWN_HOST -0x0056
33 #define POLARSSL_ERR_NET_SOCKET_FAILED -0x0042
34 #define POLARSSL_ERR_NET_CONNECT_FAILED -0x0044
35 #define POLARSSL_ERR_NET_BIND_FAILED -0x0046
36 #define POLARSSL_ERR_NET_LISTEN_FAILED -0x0048
37 #define POLARSSL_ERR_NET_ACCEPT_FAILED -0x004A
38 #define POLARSSL_ERR_NET_RECV_FAILED -0x004C
39 #define POLARSSL_ERR_NET_SEND_FAILED -0x004E
40 #define POLARSSL_ERR_NET_CONN_RESET -0x0050
41 #define POLARSSL_ERR_NET_WANT_READ -0x0052
42 #define POLARSSL_ERR_NET_WANT_WRITE -0x0054
44 #define POLARSSL_NET_LISTEN_BACKLOG 10
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
62 int net_connect( int *fd, const char *host, int port );
63 
77 int net_bind( int *fd, const char *bind_ip, int port );
78 
91 int net_accept( int bind_fd, int *client_fd, void *client_ip );
92 
100 int net_set_block( int fd );
101 
109 int net_set_nonblock( int fd );
110 
119 void net_usleep( unsigned long usec );
120 
133 int net_recv( void *ctx, unsigned char *buf, size_t len );
134 
147 int net_send( void *ctx, const unsigned char *buf, size_t len );
148 
154 void net_close( int fd );
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* net.h */
void net_usleep(unsigned long usec)
Portable usleep helper.
int net_set_nonblock(int fd)
Set the socket non-blocking.
int net_send(void *ctx, const unsigned char *buf, size_t len)
Write at most &#39;len&#39; characters.
void net_close(int fd)
Gracefully shutdown the connection.
int net_bind(int *fd, const char *bind_ip, int port)
Create a listening socket on bind_ip:port.
int net_accept(int bind_fd, int *client_fd, void *client_ip)
Accept a connection from a remote client.
int net_connect(int *fd, const char *host, int port)
Initiate a TCP connection with host:port.
int net_set_block(int fd)
Set the socket blocking.
int net_recv(void *ctx, unsigned char *buf, size_t len)
Read at most &#39;len&#39; characters.