27 #ifndef POLARSSL_NET_H
28 #define POLARSSL_NET_H
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
62 int net_connect(
int *fd,
const char *host,
int port );
77 int net_bind(
int *fd,
const char *bind_ip,
int port );
91 int net_accept(
int bind_fd,
int *client_fd,
void *client_ip );
133 int net_recv(
void *ctx,
unsigned char *buf,
size_t len );
147 int net_send(
void *ctx,
const unsigned char *buf,
size_t len );
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.