CAEN Utility  2.0.2
Utilities for CAEN projects
CAENSocket.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_CAENSOCKET_H_
38 #define CAEN_INCLUDE_CAENSOCKET_H_
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #include <types/CAENSocketTypes.h>
45 #include <CAENUtility.h>
46 
58 
66 
73 
79 
85 
89 CAEN_UTILITY_DLLAPI c_ssize_t CAEN_UTILITY_API c_recv(const c_socket_t *sckt, void *buffer, size_t totSize);
90 CAEN_UTILITY_DLLAPI c_ssize_t CAEN_UTILITY_API c_send(const c_socket_t *sckt, const void *buffer, size_t totSize);
96 CAEN_UTILITY_DLLAPI c_ssize_t CAEN_UTILITY_API c_recv_unlock(c_socket_t *sckt, void *buffer, size_t totSize);
97 CAEN_UTILITY_DLLAPI c_ssize_t CAEN_UTILITY_API c_send_lock(c_socket_t *sckt, const void *buffer, size_t totSize);
110 
119 CAEN_UTILITY_DLLAPI c_socket_t * CAEN_UTILITY_API c_accept(const c_socket_t *sckt, struct sockaddr *addr, c_socklen_t *addrlen);
120 
128 CAEN_UTILITY_DLLAPI int CAEN_UTILITY_API c_bind(const c_socket_t *sckt, const struct sockaddr *addr, c_socklen_t addrlen);
129 
136 CAEN_UTILITY_DLLAPI int CAEN_UTILITY_API c_listen(const c_socket_t *sckt, int backlog);
137 
145 CAEN_UTILITY_DLLAPI int CAEN_UTILITY_API c_connect(const c_socket_t *sckt, const struct sockaddr *addr, c_socklen_t addrlen);
157 CAEN_UTILITY_DLLAPI int32_t CAEN_UTILITY_API c_socket_server_init(c_socket_t **server, uint32_t inaddr, uint16_t *_port);
158 
165 
172 CAEN_UTILITY_DLLAPI int32_t CAEN_UTILITY_API c_socket_client_sockaddr_connect(c_socket_t **client, const struct sockaddr *addr_server, c_socklen_t addrlen);
173 
180 CAEN_UTILITY_DLLAPI int32_t CAEN_UTILITY_API c_socket_client_connect(c_socket_t **client, const char *hostname, uint16_t port);
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif // CAEN_INCLUDE_CAENSOCKET_H_
Definitions and types for CAENSocket.h.
#define CAEN_UTILITY_API
Definition: CAENUtility.h:104
int32_t c_socket_client_sockaddr_connect(c_socket_t **client, const struct sockaddr *addr_server, c_socklen_t addrlen)
Definition: CAENSocket.c:425
int c_listen(const c_socket_t *sckt, int backlog)
Definition: CAENSocket.c:298
Main header and generic tools.
int32_t c_socket_cleanup(void)
Definition: CAENSocket.c:104
void c_socket_delete(c_socket_t *socket)
Definition: CAENSocket.c:134
c_socket_t * c_accept(const c_socket_t *sckt, struct sockaddr *addr, c_socklen_t *addrlen)
Definition: CAENSocket.c:302
c_socket_t * c_tcp_socket(void)
Definition: CAENSocket.c:284
c_ssize_t c_send_lock(c_socket_t *sckt, const void *buffer, size_t totSize)
Definition: CAENSocket.c:270
c_ssize_t c_recv_unlock(c_socket_t *sckt, void *buffer, size_t totSize)
Definition: CAENSocket.c:213
int32_t c_socket_client_connect(c_socket_t **client, const char *hostname, uint16_t port)
Definition: CAENSocket.c:467
#define CAEN_UTILITY_DLLAPI
Definition: CAENUtility.h:105
#define c_nodiscard
Definition: CAENUtility.h:245
#define c_attribute_malloc
Definition: CAENUtility.h:199
ssize_t c_ssize_t
Return type of send() and recv().
int c_connect(const c_socket_t *sckt, const struct sockaddr *addr, c_socklen_t addrlen)
Definition: CAENSocket.c:312
c_socket_t * c_socket_new(void)
Definition: CAENSocket.c:124
int32_t c_socket_server_init(c_socket_t **server, uint32_t inaddr, uint16_t *_port)
Definition: CAENSocket.c:317
socklen_t c_socklen_t
See definition on Windows case.
int32_t c_socket_server_accept(const c_socket_t *server, c_socket_t **client)
Definition: CAENSocket.c:395
int c_bind(const c_socket_t *sckt, const struct sockaddr *addr, c_socklen_t addrlen)
Definition: CAENSocket.c:294
c_ssize_t c_send(const c_socket_t *sckt, const void *buffer, size_t totSize)
Definition: CAENSocket.c:228
c_ssize_t c_recv(const c_socket_t *sckt, void *buffer, size_t totSize)
Definition: CAENSocket.c:165
int32_t c_socket_init(void)
Definition: CAENSocket.c:81
void c_socket_reset(c_socket_t *socket)
Definition: CAENSocket.c:143