LibGame v0.4.0
The LG Game Engine - Copyright (C) 2024-2026 ETMSoftware
Loading...
Searching...
No Matches
tcp_socket.h
1/*
2 * libetm / tcp_socket.h - Copyright (C) Emmanuel Thomas-Maurin 2008-2026
4 *
5 * - A few TCP (stream) sockets functions -
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef INC_LIBETM_TCP_SOCKET_H
22#define INC_LIBETM_TCP_SOCKET_H
23
24#define TCP_SOCK_OK LIBETM_OK
25
26/* Timeout default values */
27#define CONNECT_TIMEOUT_SEC 5
28#define CONNECT_TIMEOUT_USEC 0
29
30#define SEND_RECV_TIMEOUT_SEC 1
31#define SEND_RECV_TIMEOUT_USEC 0
32
33#define RECV_CHUNK_LEN (16 * 1024 - 1)
34
35#ifndef WIN32_V
36typedef int sockt;
37# define TCP_SOCK_CREATE_ERROR (-1) /* socket() */
38# define TCP_SOCK_FUNC_ERROR (-1) /* setsockopt(), bind(), listen(), select(), connect(),
39 * send(), recv(), fnctl(), ioctlsocket() */
40# define CLOSE_SOCK(s) close(s)
41#else
42# include <windows.h> /* Dirty fix. */
43typedef SOCKET sockt;
44# define TCP_SOCK_CREATE_ERROR INVALID_SOCKET
45# define TCP_SOCK_FUNC_ERROR SOCKET_ERROR
46# define CLOSE_SOCK(s) closesocket(s)
47#endif
48
50
52
54
56
58
60
62
64
65void libetm_socket_set_use_proxy(zboolean);
66
68
69sockt tcp_connect_to_host(const char *, const char *);
70
72
74
75int tcp_send_full(sockt, const char *);
76
77char *tcp_recv_full(sockt, int *, int *);
78
79const char *sock_error_message();
80
81#endif /* INC_LIBETM_TCP_SOCKET_H */
char * tcp_recv_full(sockt sock, int *bytes_received, int *status)
Definition tcp_socket.c:421
int get_send_recv_timeout_sec()
Definition tcp_socket.c:73
int get_connect_timeout_usec()
Definition tcp_socket.c:139
int get_connect_timeout_sec()
Definition tcp_socket.c:117
int readable_data_is_available_on_tcp_socket(sockt sock)
Definition tcp_socket.c:351
void set_send_recv_timeout_sec(int timeout)
Definition tcp_socket.c:62
const char * sock_error_message()
Definition tcp_socket.c:470
void libetm_socket_set_use_proxy(zboolean use_proxy2)
Definition tcp_socket.c:150
int writable_data_is_available_on_tcp_socket(sockt sock)
Definition tcp_socket.c:322
void set_connect_timeout_usec(int timeout)
Definition tcp_socket.c:128
void set_connect_timeout_sec(int timeout)
Definition tcp_socket.c:106
int get_send_recv_timeout_usec()
Definition tcp_socket.c:95
int tcp_send_full(sockt sock, const char *str)
Definition tcp_socket.c:381
zboolean libetm_socket_get_use_proxy()
Definition tcp_socket.c:161
void set_send_recv_timeout_usec(int timeout)
Definition tcp_socket.c:84
sockt tcp_connect_to_host(const char *host, const char *portnum_str)
Definition tcp_socket.c:189