2008年(787)
分类:
2008-09-25 16:06:29
struct ds_socket_pack
{
int socket_fd;
const char* address;
int port;
struct sockaddr_in s_in;
struct event* pevent;
} ;
typedef struct ds_socket_pack ds_socket_pack;
ds_socket_pack* ds_socket_init(const char* address, int port);
void ds_socket_free(ds_socket_pack*);
namespace ds_socket_tcp
{
int ds_socket_client_init(ds_socket_pack*);
int ds_socket_server_init(ds_socket_pack*);
void ds_socket_client_run(ds_socket_pack*, void (*)(int, short, void *));
void ds_socket_server_run(ds_socket_pack*, void (*)(int, short, void *));
void ds_socket_dispatch(ds_socket_pack*);
int ds_recv(int fd, char**, int size, ds_socket_pack* = 0, int time_out = 0);
int ds_send(int fd, const char*, int size, ds_socket_pack* = 0);
// for TCP, the last param is no useful
}