00001
00002
00003
00004
00005
00006
00007
00008
00016
00017
00018
00019
00020 #ifndef _ALTSOCKLIB_H_
00021 #define _ALTSOCKLIB_H_
00022
00023 #include <stdlib.h>
00024
00025 #if defined(WIN32) && !defined(CYGWIN)
00026 #include <winsock.h>
00027 #else
00028 #include <sys/socket.h>
00029 #include <netinet/in.h>
00030 #include <arpa/inet.h>
00031 #endif
00032
00042 int sockopen(char *host, struct in_addr bind_add, unsigned short port);
00043 int sockinfo(int sock, unsigned char *info);
00044 int sockclose(int sock);
00045 int senddata(int socket, char *buffer, int length);
00046 int senddata_raw(int socket,const char *buffer, int length);
00047 int recvdata(int socket, char *buffer, int maxsize);
00048 void sockerror(char *msg);
00049
00051 typedef struct {
00052 char *recvbuffer;
00053 char *bufp;
00054 char *bufe;
00055 int size;
00056 } recvbuffer_t;
00057
00058 recvbuffer_t *recvBufferCreate(int size);
00059 void recvBufferDestroy(recvbuffer_t *rb);
00060 int recvstring(int socket, char *buffer, int maxsize, recvbuffer_t *r);
00061 int recvstring_with_timeout(int socket, char *buffer, int maxsize, recvbuffer_t *r, int timeout);
00062 int sendstring(int socket, char *string);
00063 int sendstring_raw(int socket,const char *string);
00064 #if defined(WIN32) && !defined(CYGWIN)
00065 void sockinit();
00066 #endif
00067
00068
00069 #endif