CAEN Utility  2.0.2
Utilities for CAEN projects
CAENSocketTypes.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * CAEN SpA - Software Division
4 * Via Vetraia, 11 - 55049 - Viareggio ITALY
5 * +39 0594 388 398 - www.caen.it
6 *
7 *******************************************************************************
8 *
9 * Copyright (C) 2019-2022 CAEN SpA
10 *
11 * This file is part of the CAEN Utility.
12 *
13 * The CAEN Utility is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 3 of the License, or (at your option) any later version.
17 *
18 * The CAEN Utility is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with the CAEN Utility; if not, see
25 * https://www.gnu.org/licenses/.
26 *
27 * SPDX-License-Identifier: LGPL-3.0-or-later
28 *
29 ***************************************************************************/
37 #ifndef CAEN_INCLUDE_TYPES_CAENSOCKETTYPES_H_
38 #define CAEN_INCLUDE_TYPES_CAENSOCKETTYPES_H_
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #ifdef _WIN32
45 #include <WinSock2.h>
46 #else
47 #include <sys/socket.h>
48 #include <errno.h>
49 #endif
50 
51 #include <types/CAENThreadTypes.h>
52 
53 typedef enum {
67 
68 #ifdef _WIN32
69 typedef SOCKET c_socket_type_t;
70 typedef int c_socklen_t;
71 typedef int c_ssize_t;
72 #define c_socket_errno WSAGetLastError()
73 #define c_socket_h_errno c_socket_errno
74 #define c_socket_invalid INVALID_SOCKET
75 #define c_socket_error SOCKET_ERROR
76 #define c_socket_max_ssize (size_t)INT_MAX
77 #else
78 typedef int c_socket_type_t;
79 typedef socklen_t c_socklen_t;
80 typedef ssize_t c_ssize_t;
81 #define c_socket_errno errno
82 #define c_socket_h_errno h_errno
83 #define c_socket_invalid (-1)
84 #define c_socket_error (c_ssize_t)(-1)
85 #define c_socket_max_ssize (size_t)SSIZE_MAX
86 #endif
87 
88 typedef struct {
89  c_socket_type_t socket;
91 } c_socket_t;
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif // CAEN_INCLUDE_TYPES_CAENSOCKETTYPES_H_
int c_socket_type_t
Return type of socket().
c_mutex_t mutex
A mutex, use by some functions.
c_socket_type_t socket
The socket.
ssize_t c_ssize_t
Return type of send() and recv().
c_Socket_ErrorCode_t
socklen_t c_socklen_t
See definition on Windows case.
pthread_mutex_t c_mutex_t
Mutex type.
Definitions and types for CAENThreadTypes.h.