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 #ifndef _OS_NOSOCKET
00031
00032 #ifdef _WIN32_WCE
00033 #include <winsock.h>
00034 #define perror(a)
00035 #elif defined(_WIN32) || defined(_WIN64)
00036 #include <sys/types.h>
00037 #define INCL_WINSOCK_API_TYPEDEFS 1
00038 #define INCL_WINSOCK_API_PROTOTYPES 0
00039 #include <winsock2.h>
00040 #include <winerror.h>
00041 #include <tchar.h>
00042 #else
00043 #include <sys/types.h>
00044 #include <sys/time.h>
00045 #include <sys/socket.h>
00046 #include <netinet/in.h>
00047 #include <netdb.h>
00048 #include <unistd.h>
00049 #include <arpa/inet.h>
00050 #endif
00051
00052 #include "rtxsrc/osSysTypes.h"
00053 #include "rtxsrc/rtxExternDefs.h"
00054
00055 #ifdef __cplusplus
00056 extern "C" {
00057 #endif
00058
00062 #if (defined (_WIN32) || defined (_WIN64)) && !defined(__SYMBIAN32__)
00063 typedef SOCKET OSRTSOCKET;
00064 #else
00065 typedef int OSRTSOCKET;
00066 #endif
00067
00068 #define OSRTSOCKET_INVALID ((OSRTSOCKET)-1)
00069
00080 typedef unsigned long OSIPADDR;
00081
00082 #define OSIPADDR_ANY ((OSIPADDR)0)
00083 #define OSIPADDR_LOCAL ((OSIPADDR)0x7f000001UL)
00084
00085 struct in_addr;
00086
00106 EXTERNRT int rtxSocketAccept (OSRTSOCKET socket, OSRTSOCKET *pNewSocket,
00107 OSIPADDR* destAddr, int* destPort);
00108
00119 EXTERNRT int rtxSocketAddrToStr (OSIPADDR ipAddr, char* pbuf, size_t bufsize);
00120
00134 EXTERNRT int rtxSocketBind (OSRTSOCKET socket, OSIPADDR addr, int port);
00135
00144 EXTERNRT int rtxSocketClose (OSRTSOCKET socket);
00145
00161 EXTERNRT int rtxSocketConnect (OSRTSOCKET socket, const char* host, int port);
00162
00179 EXTERNRT int rtxSocketConnectTimed
00180 (OSRTSOCKET socket, const char* host, int port, int nsecs);
00181
00190 EXTERNRT int rtxSocketCreate (OSRTSOCKET* psocket);
00191
00192
00193
00194
00195
00196
00197
00198
00199 EXTERNRT int rtxSocketCreateUDP (OSRTSOCKET *psocket);
00200
00210 EXTERNRT int rtxSocketGetHost (const char* host, struct in_addr *inaddr);
00211
00219 EXTERNRT int rtxSocketsInit ();
00220
00236 EXTERNRT int rtxSocketListen (OSRTSOCKET socket, int maxConnection);
00237
00253 EXTERNRT int rtxSocketParseURL
00254 (char* url, char** protocol, char** address, int* port);
00255
00268 EXTERNRT int rtxSocketRecv (OSRTSOCKET socket, OSOCTET* pbuf, size_t bufsize);
00269
00287 EXTERNRT int rtxSocketSelect (int nfds, fd_set* readfds, fd_set* writefds,
00288 fd_set* exceptfds, struct timeval* timeout);
00289
00302 EXTERNRT int rtxSocketSend
00303 (OSRTSOCKET socket, const OSOCTET* pdata, size_t size);
00304
00314 EXTERNRT int rtxSocketSetBlocking (OSRTSOCKET socket, OSBOOL value);
00315
00328 EXTERNRT int rtxSocketStrToAddr (const char* pIPAddrStr, OSIPADDR* pIPAddr);
00329
00333 #ifdef __cplusplus
00334 }
00335 #endif
00336
00337 #endif
00338
00339 #endif
00340