00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00029
#ifndef _RTSOCKET_H_
00030
#define _RTSOCKET_H_
00031
00032
#ifdef _WIN32_WCE
00033
#include <winsock.h>
00034
#elif defined(_WIN32) || defined(_WIN64)
00035
#include <sys/types.h>
00036
#ifdef INCL_WINSOCK_API_TYPEDEFS
00037
#undef INCL_WINSOCK_API_TYPEDEFS
00038
#endif
00039
#ifdef INCL_WINSOCK_API_PROTOTYPES
00040
#undef INCL_WINSOCK_API_PROTOTYPES
00041
#endif
00042
#define INCL_WINSOCK_API_TYPEDEFS 1
00043
#define INCL_WINSOCK_API_PROTOTYPES 0
00044
#include <winsock2.h>
00045
#else
00046
#include <sys/types.h>
00047
#include <sys/socket.h>
00048
#include <netinet/in.h>
00049
#include <netdb.h>
00050
#include <unistd.h>
00051
#include <arpa/inet.h>
00052
#endif
00053
00054
#include "asn1type.h"
00055
00056
#ifdef __cplusplus
00057
extern "C" {
00058
#endif
00059
00060
#if defined (_WIN32) || defined (_WIN64)
00061
typedef SOCKET
OSRTSOCKET;
00062
#else
00063 typedef int OSRTSOCKET;
00064
#endif
00065
00066
#define OSRTSOCKET_INVALID ((OSRTSOCKET)-1)
00067
00074 typedef unsigned long OSIPADDR;
00075
00076
#define OSIPADDR_ANY ((OSIPADDR)0)
00077
#define OSIPADDR_LOCAL ((OSIPADDR)0x7f000001UL)
00078
#define OSIPADDR_INVALID ((OSIPADDR)0xffffffffUL)
00079
00104 EXTERNRT
int rtSocketAccept (OSRTSOCKET socket, OSRTSOCKET *pNewSocket,
00105 OSIPADDR* destAddr,
int* destPort);
00106
00117 EXTERNRT
int rtSocketAddrToStr (OSIPADDR ipAddr,
char* pbuf,
int bufsize);
00118
00132 EXTERNRT
int rtSocketBind (OSRTSOCKET socket, OSIPADDR addr,
int port);
00133
00146 EXTERNRT
int rtSocketBlockingRead
00147 (
OSRTSOCKET socket, ASN1OCTET* pbuf, size_t readBytes);
00148
00157 EXTERNRT
int rtSocketClose (OSRTSOCKET socket);
00158
00174 EXTERNRT
int rtSocketConnect (OSRTSOCKET socket,
const char* host,
int port);
00175
00185 EXTERNRT
int rtSocketCreate (OSRTSOCKET* psocket);
00186
00195 EXTERNRT
int rtSocketCreateUDP (OSRTSOCKET* psocket);
00196
00204 EXTERNRT
int rtSocketsInit (
void);
00205
00213 EXTERNRT
int rtSocketsCleanup (
void);
00214
00230 EXTERNRT
int rtSocketListen (OSRTSOCKET socket,
int maxConnection);
00231
00244 EXTERNRT
int rtSocketRecv (OSRTSOCKET socket, ASN1OCTET* pbuf,
00245 ASN1UINT bufsize);
00246
00265 EXTERNRT
int rtSocketRecvFrom (OSRTSOCKET socket, ASN1OCTET* pbuf,
00266 ASN1UINT bufsize,
char * remotehost,
00267
int * remoteport);
00268
00281 EXTERNRT
int rtSocketSend
00282 (
OSRTSOCKET socket,
const ASN1OCTET* pdata, ASN1UINT size);
00283
00300 EXTERNRT
int rtSocketSendTo(OSRTSOCKET socket,
const ASN1OCTET* pdata,
00301 ASN1UINT size,
const char* remotehost,
00302
int remoteport);
00303
00322 EXTERNRT
int rtSocketSelect(
int nfds, fd_set *readfds, fd_set *writefds,
00323 fd_set *exceptfds,
struct timeval * timeout);
00324
00337 EXTERNRT
int rtSocketStrToAddr (
const char* pIPAddrStr, OSIPADDR* pIPAddr);
00338
00349 EXTERNRT
int rtSocketGetLocalIPAddress(
char * pIPAddrs,
int bufSize);
00351
#ifdef __cplusplus
00352
}
00353
#endif
00354
00355
#endif