1#ifndef __PHSOCKET__H__
2#define __PHSOCKET__H__
3
4#ifdef _WIN32
5#include <winsock.h>
6#else
7#include <sys/types.h>
8#include <sys/socket.h>
9#include <sys/ioctl.h>
10#include <netinet/in.h>
11#include <arpa/inet.h>
12#include <unistd.h>
13#include <errno.h>
14#include <netdb.h>
15#include <string.h>
16#include <time.h>
17#include <sys/time.h>
18#include <sys/timeb.h>
19
20#endif
21#ifndef BOOL
22#define BOOL unsigned int
23#endif
24
25#ifndef TRUE
26#define TRUE 1
27#endif
28
29#ifndef FALSE
30#define FALSE 0
31#endif
32
33#ifndef NULL
34#define NULL 0
35#endif
36
37int phReadOneLine(int m_hSocket, char * lpszBuf, int nBufLen);
38void phSetBlockingMode(int m_hSocket, BOOL bBlocking);
39
40BOOL	phAccept(int m_hSocket, int *rSocket, struct sockaddr_in* lpSockAddr, int* lpSockAddrLen);
41BOOL	phBind(int m_hSocket, unsigned short nSocketPort, char *lpszSocketAddress);
42void	phClose(int *m_hSocket);
43BOOL	phConnect(int m_hSocket, char *lpszHostAddress, unsigned short nHostPort, int *nAddressIndex, char *szSelectedAddress);
44BOOL	phrawConnect(int m_hSocket, struct sockaddr_in* pSockAddr, int nSockAddrLen);
45BOOL	phListen(int m_hSocket, int nConnectionBacklog);
46int		phReceive(int m_hSocket, void* lpBuf, int nBufLen, int nFlag);
47int		phReceiveFrom(int m_hSocket, void* lpBuf, int nBufLen, char *rSocketAddress, unsigned short *rSocketPort, int nFlags);
48int		phrawReceiveFrom(int m_hSocket, void* lpBuf, int nBufLen, struct sockaddr_in* pSockAddr, int* pnSockAddrLen, int nFlags);
49int		phSend(int m_hSocket, void* lpBuf, int nBufLen, int nFlag);
50int		phSendTo(int m_hSocket, const void* lpBuf, int nBufLen, unsigned short nHostPort, char *lpszHostAddress, int nFlags);
51int		phrawSendTo(int m_hSocket, const void* lpBuf, int nBufLen, struct sockaddr_in* pSockAddr, int nSockAddrLen, int nFlags);
52BOOL	phCreate(int *m_hSocket, unsigned short nSocketPort, int nSocketType, char *lpszSocketAddress);
53int		phDataReadable(int m_hSocket, int nTimeout); //in Seconds
54
55#endif