00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00027 #ifndef _RTXSOCKET_H_
00028 #define _RTXSOCKET_H_
00029
00030 #ifdef _WIN32_WCE
00031 #include <winsock.h>
00032 #define perror(a)
00033 #elif defined(_WIN32) || defined(_WIN64)
00034 #include <sys/types.h>
00035 #define INCL_WINSOCK_API_TYPEDEFS 1
00036 #define INCL_WINSOCK_API_PROTOTYPES 0
00037 #include <winsock2.h>
00038 #include <winerror.h>
00039 #include <tchar.h>
00040 #else
00041 #include <sys/types.h>
00042 #include <sys/time.h>
00043 #include <sys/socket.h>
00044 #include <netinet/in.h>
00045 #include <netdb.h>
00046 #include <unistd.h>
00047 #include <arpa/inet.h>
00048 #endif
00049
00050 #include "rtxsrc/osSysTypes.h"
00051 #include "rtxsrc/rtxExternDefs.h"
00052
00053 #ifdef __cplusplus
00054 extern "C" {
00055 #endif
00056
00060 #if (defined (_WIN32) || defined (_WIN64)) && !defined(__SYMBIAN32__)
00061 typedef SOCKET OSRTSOCKET;
00062 #else
00063 typedef int OSRTSOCKET;
00064 #endif
00065
00066 #define OSRTSOCKET_INVALID ((OSRTSOCKET)-1)
00067
00078 typedef unsigned long OSIPADDR;
00079
00080 #define OSIPADDR_ANY ((OSIPADDR)0)
00081 #define OSIPADDR_LOCAL ((OSIPADDR)0x7f000001UL)
00082
00083 struct in_addr;
00084
00104 EXTERNRT int rtxSocketAccept (OSRTSOCKET socket, OSRTSOCKET *pNewSocket,
00105 OSIPADDR* destAddr, int* destPort);
00106
00117 EXTERNRT int rtxSocketAddrToStr (OSIPADDR ipAddr, char* pbuf, size_t bufsize);
00118
00132 EXTERNRT int rtxSocketBind (OSRTSOCKET socket, OSIPADDR addr, int port);
00133
00142 EXTERNRT int rtxSocketClose (OSRTSOCKET socket);
00143
00159 EXTERNRT int rtxSocketConnect (OSRTSOCKET socket, const char* host, int port);
00160
00177 EXTERNRT int rtxSocketConnectTimed
00178 (OSRTSOCKET socket, const char* host, int port, int nsecs);
00179
00188 EXTERNRT int rtxSocketCreate (OSRTSOCKET* psocket);
00189
00190
00191
00192
00193
00194
00195
00196
00197 EXTERNRT int rtxSocketCreateUDP (OSRTSOCKET *psocket);
00198
00208 EXTERNRT int rtxSocketGetHost (const char* host, struct in_addr *inaddr);
00209
00217 EXTERNRT int rtxSocketsInit ();
00218
00234 EXTERNRT int rtxSocketListen (OSRTSOCKET socket, int maxConnection);
00235
00251 EXTERNRT int rtxSocketParseURL
00252 (char* url, char** protocol, char** address, int* port);
00253
00266 EXTERNRT int rtxSocketRecv (OSRTSOCKET socket, OSOCTET* pbuf, size_t bufsize);
00267
00285 EXTERNRT int rtxSocketSelect (int nfds, fd_set* readfds, fd_set* writefds,
00286 fd_set* exceptfds, struct timeval* timeout);
00287
00300 EXTERNRT int rtxSocketSend
00301 (OSRTSOCKET socket, const OSOCTET* pdata, size_t size);
00302
00312 EXTERNRT int rtxSocketSetBlocking (OSRTSOCKET socket, OSBOOL value);
00313
00326 EXTERNRT int rtxSocketStrToAddr (const char* pIPAddrStr, OSIPADDR* pIPAddr);
00327
00331 #ifdef __cplusplus
00332 }
00333 #endif
00334
00335 #endif
00336