include
ur_client_library
comm
socket_t.h
Go to the documentation of this file.
1
/*
2
* Copyright 2024, RoboDK Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
19
#ifdef _WIN32
20
21
# define NOMINMAX
22
# define WIN32_LEAN_AND_MEAN
23
# include <WinSock2.h>
24
# include <ws2tcpip.h>
25
26
# ifndef TCP_QUICKACK
27
# define TCP_QUICKACK 12
28
# endif
29
30
# ifdef ERROR
31
# undef ERROR
32
# endif // ERROR
33
34
typedef
SOCKET
socket_t
;
35
typedef
SSIZE_T ssize_t;
36
37
static
inline
int
ur_setsockopt
(
socket_t
s,
int
level,
int
optname,
const
void
* optval,
unsigned
int
optlen)
38
{
39
return ::setsockopt(s, level, optname,
reinterpret_cast<
const
char
*
>
(optval),
static_cast<
int
>
(optlen));
40
}
41
42
static
inline
int
ur_close
(
socket_t
s)
43
{
44
return ::closesocket(s);
45
}
46
47
#else // _WIN32
48
49
# include <arpa/inet.h>
50
# include <netdb.h>
51
# include <sys/select.h>
52
# include <sys/socket.h>
53
# include <sys/time.h>
54
# include <sys/types.h>
55
# include <unistd.h>
56
57
typedef
int
socket_t
;
58
59
# ifndef INVALID_SOCKET
60
# define INVALID_SOCKET (-1)
61
# endif
62
63
# define ur_setsockopt setsockopt
64
# define ur_close close
65
66
#endif // _WIN32
socket_t
int socket_t
Definition:
socket_t.h:57
ur_setsockopt
#define ur_setsockopt
Definition:
socket_t.h:63
ur_close
#define ur_close
Definition:
socket_t.h:64
ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Mon May 26 2025 02:35:58