00001
00004 #ifndef _NET_H
00005 #define _NET_H
00006
00007 #ifdef __cplusplus
00008 extern "C" {
00009 #endif
00010
00011 #define ERR_NET_UNKNOWN_HOST 0xFF10
00012 #define ERR_NET_SOCKET_FAILED 0xFF20
00013 #define ERR_NET_CONNECT_FAILED 0xFF20
00014 #define ERR_NET_BIND_FAILED 0xFF30
00015 #define ERR_NET_LISTEN_FAILED 0xFF40
00016 #define ERR_NET_ACCEPT_FAILED 0xFF50
00017 #define ERR_NET_RECV_FAILED 0xFF60
00018 #define ERR_NET_SEND_FAILED 0xFF70
00019 #define ERR_NET_CONN_RESET 0xFF80
00020 #define ERR_NET_WOULD_BLOCK 0xFF90
00021
00030 int net_connect( int *fd, char *host, unsigned int port );
00031
00041 int net_bind( int *fd, char *bind_ip, unsigned int port );
00042
00050 int net_accept( int bind_fd, int *client_fd,
00051 unsigned char client_ip[4] );
00052
00058 int net_set_nonblock( int fd );
00059
00066 void net_usleep( unsigned long usec );
00067
00076 int net_recv( int fd, unsigned char *buf, int *len );
00077
00086 int net_send( int fd, unsigned char *buf, int *len );
00087
00091 void net_close( int fd );
00092
00093 #ifdef __cplusplus
00094 }
00095 #endif
00096
00097 #endif