C API for BALTECH SDK
tcpip_protocol.h
Go to the documentation of this file.
1 
10 #ifndef __TCP_CHANNEL_H__
11 #define __TCP_CHANNEL_H__
12 
13 
14 #include "protocol.h"
15 
16 
21 #if ! defined(BRP_NO_SOCKET_HEADERS)
22 
31  #if defined(_WIN32)
32  #include <ws2tcpip.h>
33  typedef int socklen_t;
34  // this is only required for MingW (as definition is missing):
35  #ifdef __GNUC__
36  PCSTR WSAAPI inet_ntop(INT Family, PVOID pAddr, PSTR pStringBuf,
37  size_t StringBufSize);
38  #endif
39  #else
40  #include <unistd.h>
41  #include <sys/socket.h>
42  #include <netdb.h>
43  #include <sys/ioctl.h>
44  #include <arpa/inet.h>
45  #define closesocket close
46  #define ioctlsocket ioctl
47  #define INVALID_SOCKET (-1)
48  #define SOCKET_ERROR (-1)
49  #define SD_BOTH SHUT_RDWR
50  #define NO_ERROR 0
51  typedef int SOCKET;
52  #endif
53 #endif
54 
66 #if ! defined(BRP_DEFAULT_TCP_PORT)
67  #define BRP_DEFAULT_TCP_PORT 2939
68 #endif
69 
70 
84 #define BRP_DEFAULT_TCPIP_ROUNDTRIP_TIMEOUT 1500
85 
86 
95 (
96  char * ipaddr
97 );
100 
101 
116 (
117 #if defined(_WIN32)
118  SOCKET socket
119 #else
121  int socket
122 #endif
123 );
124 
125 
131 BRP_LIB char * brp_get_tcpip_ipaddr
132 (
133  brp_protocol protocol
134 );
135 
136 
142 (
143  brp_protocol protocol,
144  brp_time timeout
145 );
146 
147 
156 (
157  brp_protocol protocol
158 );
159 
160 
161 #endif
162  // end of defgroup brp_lib
BRP_LIB brp_protocol brp_create_tcpip_by_socket(int socket)
Creates a TCP/IP protocol from an OS-level socket that was created by the user of the BRP library...
unsigned int brp_errcode
This type is used library-wide for passing error codes in the return value of functions.
Definition: errorcodes.h:23
BRP_LIB brp_time brp_get_tcpip_roundtrip_timeout(brp_protocol protocol)
Retrieves the value of the roundtrip timeout set by the last brp_set_tcpip_roundtrip_timeout().
struct brp_protocol_t * brp_protocol
This is a generic handle of a protocol.
Definition: protocol.h:34
BRP_LIB brp_protocol brp_create_tcpip(char *ipaddr)
Creates a TCP/IP protocol from an IP address.
unsigned long brp_time
absolute/relative timeout/delay in ms.
Definition: common.h:67
This file primarly defines the common part of all protocol&#39;s data structures (:brp_protocol_t) and AP...
BRP_LIB brp_errcode brp_set_tcpip_roundtrip_timeout(brp_protocol protocol, brp_time timeout)
If the value of BRP_DEFAULT_TCPIP_ROUNDTRIP_TIMEOUT is not appropriate it can be finetuned for specif...
BRP_LIB char * brp_get_tcpip_ipaddr(brp_protocol protocol)
Retrieves the ipaddr set in brp_create_tcpip().