mbed TLS v1.3.16
net.h
Go to the documentation of this file.
1 
24 #ifndef POLARSSL_NET_H
25 #define POLARSSL_NET_H
26 
27 #include <stddef.h>
28 
29 #define POLARSSL_ERR_NET_UNKNOWN_HOST -0x0056
30 #define POLARSSL_ERR_NET_SOCKET_FAILED -0x0042
31 #define POLARSSL_ERR_NET_CONNECT_FAILED -0x0044
32 #define POLARSSL_ERR_NET_BIND_FAILED -0x0046
33 #define POLARSSL_ERR_NET_LISTEN_FAILED -0x0048
34 #define POLARSSL_ERR_NET_ACCEPT_FAILED -0x004A
35 #define POLARSSL_ERR_NET_RECV_FAILED -0x004C
36 #define POLARSSL_ERR_NET_SEND_FAILED -0x004E
37 #define POLARSSL_ERR_NET_CONN_RESET -0x0050
38 #define POLARSSL_ERR_NET_WANT_READ -0x0052
39 #define POLARSSL_ERR_NET_WANT_WRITE -0x0054
41 #define POLARSSL_NET_LISTEN_BACKLOG 10
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
59 int net_connect( int *fd, const char *host, int port );
60 
74 int net_bind( int *fd, const char *bind_ip, int port );
75 
88 int net_accept( int bind_fd, int *client_fd, void *client_ip );
89 
97 int net_set_block( int fd );
98 
106 int net_set_nonblock( int fd );
107 
116 void net_usleep( unsigned long usec );
117 
130 int net_recv( void *ctx, unsigned char *buf, size_t len );
131 
144 int net_send( void *ctx, const unsigned char *buf, size_t len );
145 
151 void net_close( int fd );
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 #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 'len' 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 'len' characters.