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 < 10 (as definition is missing)
35  // https://github.com/mirror/mingw-w64/commit/5fe3a72687f0629b68333fa438f4389db790651b
36  #if defined(__GNUC__) && !defined(InetNtopA)
37  PCSTR WSAAPI inet_ntop(INT Family, PVOID pAddr, PSTR pStringBuf,
38  size_t StringBufSize);
39  #endif
40  #else
41  #include <unistd.h>
42  #include <sys/socket.h>
43  #include <netdb.h>
44  #include <sys/ioctl.h>
45  #include <arpa/inet.h>
46  #define closesocket close
47  #define ioctlsocket ioctl
48  #define INVALID_SOCKET (-1)
49  #define SOCKET_ERROR (-1)
50  #define SD_BOTH SHUT_RDWR
51  #define NO_ERROR 0
52  typedef int SOCKET;
53  #endif
54 #endif
55 
67 #if ! defined(BRP_DEFAULT_TCP_PORT)
68  #define BRP_DEFAULT_TCP_PORT 2939
69 #endif
70 
71 
85 #define BRP_DEFAULT_TCPIP_ROUNDTRIP_TIMEOUT 1500
86 
87 
96 (
97  char * ipaddr
98 );
101 
102 
117 (
118 #if defined(_WIN32)
119  SOCKET socket
120 #else
122  int socket
123 #endif
124 );
125 
126 
132 BRP_LIB char * brp_get_tcpip_ipaddr
133 (
134  brp_protocol protocol
135 );
136 
137 
143 (
144  brp_protocol protocol,
145  brp_time timeout
146 );
147 
148 
157 (
158  brp_protocol protocol
159 );
160 
161 
162 #endif
163  // 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().