ASN1C C/C++ Common Runtime  ASN1C v7.5.x
rtxSocket.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2021 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 
270 EXTERNRT int rtxSocketRecv (OSRTSOCKET socket, OSOCTET* pbuf, size_t bufsize);
271 
288 EXTERNRT int rtxSocketRecvTimed
289 (OSRTSOCKET socket, OSOCTET* pbuf, size_t bufsize, OSUINT32 secs);
290 
308 EXTERNRT int rtxSocketSelect (int nfds, fd_set* readfds, fd_set* writefds,
309  fd_set* exceptfds, struct timeval* timeout);
310 
323 EXTERNRT int rtxSocketSend
324 (OSRTSOCKET socket, const OSOCTET* pdata, size_t size);
325 
335 EXTERNRT int rtxSocketSetBlocking (OSRTSOCKET socket, OSBOOL value);
336 
349 EXTERNRT int rtxSocketStrToAddr (const char* pIPAddrStr, OSIPADDR* pIPAddr);
350 
354 #ifdef __cplusplus
355 }
356 #endif
357 
358 #endif /* _OS_NOSOCKET */
359 
360 #endif /* _RTXSOCKET_H_ */
361 
int rtxSocketSend(OSRTSOCKET socket, const OSOCTET *pdata, size_t size)
int rtxSocketsInit(OSVOIDARG)
int OSRTSOCKET
Definition: rtxSocket.h:65
int rtxSocketClose(OSRTSOCKET socket)
int rtxSocketParseURL(char *url, char **protocol, char **address, int *port)
int rtxSocketConnectTimed(OSRTSOCKET socket, const char *host, int port, int nsecs)
int rtxSocketSelect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
int rtxSocketBind(OSRTSOCKET socket, OSIPADDR addr, int port)
int rtxSocketAccept(OSRTSOCKET socket, OSRTSOCKET *pNewSocket, OSIPADDR *destAddr, int *destPort)
int rtxSocketAddrToStr(OSIPADDR ipAddr, char *pbuf, size_t bufsize)
int rtxSocketSetBlocking(OSRTSOCKET socket, OSBOOL value)
int rtxSocketCreate(OSRTSOCKET *psocket)
int rtxSocketRecvTimed(OSRTSOCKET socket, OSOCTET *pbuf, size_t bufsize, OSUINT32 secs)
int rtxSocketRecv(OSRTSOCKET socket, OSOCTET *pbuf, size_t bufsize)
int rtxSocketListen(OSRTSOCKET socket, int maxConnection)
int rtxSocketGetHost(const char *host, struct in_addr *inaddr)
int rtxSocketConnect(OSRTSOCKET socket, const char *host, int port)
unsigned long OSIPADDR
Definition: rtxSocket.h:80
int rtxSocketStrToAddr(const char *pIPAddrStr, OSIPADDR *pIPAddr)