00001
00002
00003
00007 #ifndef _NET_H
00008 #define _NET_H
00009
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013
00014 #define ERR_NET_UNKNOWN_HOST 0xFF10
00015 #define ERR_NET_SOCKET_FAILED 0xFF20
00016 #define ERR_NET_CONNECT_FAILED 0xFF20
00017 #define ERR_NET_BIND_FAILED 0xFF30
00018 #define ERR_NET_LISTEN_FAILED 0xFF40
00019 #define ERR_NET_ACCEPT_FAILED 0xFF50
00020 #define ERR_NET_RECV_FAILED 0xFF60
00021 #define ERR_NET_SEND_FAILED 0xFF70
00022 #define ERR_NET_CONN_RESET 0xFF80
00023 #define ERR_NET_WOULD_BLOCK 0xFF90
00024
00033 int net_connect( int *fd, char *host, unsigned int port );
00034
00044 int net_bind( int *fd, char *bind_ip, unsigned int port );
00045
00053 int net_accept( int bind_fd, int *client_fd,
00054 unsigned char client_ip[4] );
00055
00061 int net_set_nonblock( int fd );
00062
00069 void net_usleep( unsigned long usec );
00070
00079 int net_recv( int fd, unsigned char *buf, int *len );
00080
00089 int net_send( int fd, unsigned char *buf, int *len );
00090
00094 void net_close( int fd );
00095
00096 #ifdef __cplusplus
00097 }
00098 #endif
00099
00100 #endif