XBinder  Version 2.6.x
rtxSocket.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2018 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
27 #ifndef _RTXSOCKET_H_
28 #define _RTXSOCKET_H_
29 
30 #ifndef _OS_NOSOCKET
31 
32 #ifdef _WIN32_WCE
33 #include <winsock.h>
34 #define perror(a)
35 #elif defined(_WIN32) || defined(_WIN64)
36 #include <sys/types.h>
37 #define INCL_WINSOCK_API_TYPEDEFS 1
38 #define INCL_WINSOCK_API_PROTOTYPES 0
39 #include <winsock2.h>
40 #include <winerror.h>
41 #include <tchar.h>
42 #else
43 #include <sys/types.h>
44 #include <sys/time.h>
45 #include <sys/socket.h>
46 #include <netinet/in.h>
47 #include <netdb.h>
48 #include <unistd.h>
49 #include <arpa/inet.h>
50 #endif
51 
52 #include "rtxsrc/osSysTypes.h"
53 #include "rtxsrc/rtxExternDefs.h"
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
62 #if (defined (_WIN32) || defined (_WIN64)) && !defined(__SYMBIAN32__)
63 typedef SOCKET OSRTSOCKET;
64 #else
65 typedef int OSRTSOCKET;
66 #endif
67 
68 #define OSRTSOCKET_INVALID ((OSRTSOCKET)-1)
69 
80 typedef unsigned long OSIPADDR;
81 
82 #define OSIPADDR_ANY ((OSIPADDR)0)
83 #define OSIPADDR_LOCAL ((OSIPADDR)0x7f000001UL) /* 127.0.0.1 */
84 
85 struct in_addr;
86 
106 EXTERNRT int rtxSocketAccept (OSRTSOCKET socket, OSRTSOCKET *pNewSocket,
107  OSIPADDR* destAddr, int* destPort);
108 
119 EXTERNRT int rtxSocketAddrToStr (OSIPADDR ipAddr, char* pbuf, size_t bufsize);
120 
134 EXTERNRT int rtxSocketBind (OSRTSOCKET socket, OSIPADDR addr, int port);
135 
144 EXTERNRT int rtxSocketClose (OSRTSOCKET socket);
145 
161 EXTERNRT int rtxSocketConnect (OSRTSOCKET socket, const char* host, int port);
162 
179 EXTERNRT int rtxSocketConnectTimed
180 (OSRTSOCKET socket, const char* host, int port, int nsecs);
181 
190 EXTERNRT int rtxSocketCreate (OSRTSOCKET* psocket);
191 
192 /*
193  * This function creates a UDP socket.
194  *
195  * @param psocket The Pointer to the socket handle variable to receive
196  * the handle of the new socket.
197  *
198  * @return 0 upon success, < 0 upon failure. */
199 EXTERNRT int rtxSocketCreateUDP (OSRTSOCKET *psocket);
200 
210 EXTERNRT int rtxSocketGetHost (const char* host, struct in_addr *inaddr);
211 
219 EXTERNRT int rtxSocketsInit (OSVOIDARG);
220 
236 EXTERNRT int rtxSocketListen (OSRTSOCKET socket, int maxConnection);
237 
253 EXTERNRT int rtxSocketParseURL
254 (char* url, char** protocol, char** address, int* port);
255 
268 EXTERNRT int rtxSocketRecv (OSRTSOCKET socket, OSOCTET* pbuf, size_t bufsize);
269 
286 EXTERNRT int rtxSocketRecvTimed
287 (OSRTSOCKET socket, OSOCTET* pbuf, size_t bufsize, OSUINT32 secs);
288 
306 EXTERNRT int rtxSocketSelect (int nfds, fd_set* readfds, fd_set* writefds,
307  fd_set* exceptfds, struct timeval* timeout);
308 
321 EXTERNRT int rtxSocketSend
322 (OSRTSOCKET socket, const OSOCTET* pdata, size_t size);
323 
333 EXTERNRT int rtxSocketSetBlocking (OSRTSOCKET socket, OSBOOL value);
334 
347 EXTERNRT int rtxSocketStrToAddr (const char* pIPAddrStr, OSIPADDR* pIPAddr);
348 
352 #ifdef __cplusplus
353 }
354 #endif
355 
356 #endif /* _OS_NOSOCKET */
357 
358 #endif /* _RTXSOCKET_H_ */
359 
EXTERNRT int rtxSocketRecv(OSRTSOCKET socket, OSOCTET *pbuf, size_t bufsize)
This function receives data from a connected socket.
EXTERNRT int rtxSocketConnectTimed(OSRTSOCKET socket, const char *host, int port, int nsecs)
This function establishes a connection to a specified socket.
EXTERNRT int rtxSocketAccept(OSRTSOCKET socket, OSRTSOCKET *pNewSocket, OSIPADDR *destAddr, int *destPort)
This function permits an incoming connection attempt on a socket.
EXTERNRT int rtxSocketsInit(OSVOIDARG)
This function initiates use of sockets by an application.
int OSRTSOCKET
Socket handle type definition.
Definition: rtxSocket.h:65
EXTERNRT int rtxSocketParseURL(char *url, char **protocol, char **address, int *port)
This function parses a simple URL of the form <protocol>://<address>:<port> into its individual compo...
EXTERNRT int rtxSocketConnect(OSRTSOCKET socket, const char *host, int port)
This function establishes a connection to a specified socket.
EXTERNRT int rtxSocketAddrToStr(OSIPADDR ipAddr, char *pbuf, size_t bufsize)
This function converts an IP address to its string representation.
EXTERNRT int rtxSocketStrToAddr(const char *pIPAddrStr, OSIPADDR *pIPAddr)
This function converts the string with IP address to a double word representation.
EXTERNRT int rtxSocketSetBlocking(OSRTSOCKET socket, OSBOOL value)
This function turns blocking mode for a socket on or off.
EXTERNRT int rtxSocketCreate(OSRTSOCKET *psocket)
This function creates a TCP socket.
EXTERNRT int rtxSocketBind(OSRTSOCKET socket, OSIPADDR addr, int port)
This function associates a local address with a socket.
EXTERNRT int rtxSocketClose(OSRTSOCKET socket)
This function closes an existing socket.
EXTERNRT int rtxSocketListen(OSRTSOCKET socket, int maxConnection)
This function places a socket a state where it is listening for an incoming connection.
EXTERNRT int rtxSocketSelect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
This function is used for synchronous monitoring of multiple sockets.
EXTERNRT int rtxSocketGetHost(const char *host, struct in_addr *inaddr)
This function resolves the given host name to an IP address.
EXTERNRT int rtxSocketSend(OSRTSOCKET socket, const OSOCTET *pdata, size_t size)
This function sends data on a connected socket.
Common definitions of external function modifiers used to define the scope of functions used in DLL&#39;s...
unsigned long OSIPADDR
The IP address represented as unsigned long value.
Definition: rtxSocket.h:80
EXTERNRT int rtxSocketRecvTimed(OSRTSOCKET socket, OSOCTET *pbuf, size_t bufsize, OSUINT32 secs)
This function receives data from a connected socket on a timed basis.