LibGame  v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
tcp_socket.c File Reference

Macros

#define FPRINTF2(stream, ...)
 

Functions

void set_send_recv_timeout_sec (int timeout)
 
int get_send_recv_timeout_sec ()
 
void set_send_recv_timeout_usec (int timeout)
 
int get_send_recv_timeout_usec ()
 
void set_connect_timeout_sec (int timeout)
 
int get_connect_timeout_sec ()
 
void set_connect_timeout_usec (int timeout)
 
int get_connect_timeout_usec ()
 
void libetm_socket_set_use_proxy (zboolean use_proxy2)
 
zboolean libetm_socket_get_use_proxy ()
 
sockt tcp_connect_to_host (const char *host, const char *portnum_str)
 
int writable_data_is_available_on_tcp_socket (sockt sock)
 
int readable_data_is_available_on_tcp_socket (sockt sock)
 
int tcp_send_full (sockt sock, const char *str)
 
char * tcp_recv_full (sockt sock, int *bytes_received, int *status)
 
const char * sock_error_message ()
 

Detailed Description

 === TCP sockets funcs ===

Macro Definition Documentation

◆ FPRINTF2

#define FPRINTF2 (   stream,
  ... 
)
Value:
{\
fprintf(stream, ## __VA_ARGS__);\
fflush(stream);\
}

Function Documentation

◆ set_send_recv_timeout_sec()

void set_send_recv_timeout_sec ( int  timeout)

...

◆ get_send_recv_timeout_sec()

int get_send_recv_timeout_sec ( )

...

◆ set_send_recv_timeout_usec()

void set_send_recv_timeout_usec ( int  timeout)

...

◆ get_send_recv_timeout_usec()

int get_send_recv_timeout_usec ( )

...

◆ set_connect_timeout_sec()

void set_connect_timeout_sec ( int  timeout)

...

◆ get_connect_timeout_sec()

int get_connect_timeout_sec ( )

...

◆ set_connect_timeout_usec()

void set_connect_timeout_usec ( int  timeout)

...

◆ get_connect_timeout_usec()

int get_connect_timeout_usec ( )

...

◆ libetm_socket_set_use_proxy()

void libetm_socket_set_use_proxy ( zboolean  use_proxy2)

Default is not using proxy, otherwise must be set.

◆ libetm_socket_get_use_proxy()

zboolean libetm_socket_get_use_proxy ( )

...

◆ tcp_connect_to_host()

sockt tcp_connect_to_host ( const char *  host,
const char *  portnum_str 
)

Open stream socket in non-blocking mode and connect to host. Return socket fd (> 0) / TCP_SOCK_CREATE_ERROR (-1 on Linux) if error.

◆ writable_data_is_available_on_tcp_socket()

int writable_data_is_available_on_tcp_socket ( sockt  sock)

...

◆ readable_data_is_available_on_tcp_socket()

int readable_data_is_available_on_tcp_socket ( sockt  sock)

...

◆ tcp_send_full()

int tcp_send_full ( sockt  sock,
const char *  str 
)

Return n bytes sent or TCP_SOCK_FUNC_ERROR (-1 on Linux) if error (connection closed by server or ?)

◆ tcp_recv_full()

char* tcp_recv_full ( sockt  sock,
int *  bytes_received,
int *  status 
)

Return response = tcp_recv_full(socket, &bytes_received, &status) or NULL if error. -> status = TCP_SOCK_OK, CONNECTION_CLOSED_BY_SERVER, TCP_SOCK_FUNC_ERROR or TCP_SOCK_SHOULD_BE_CLOSED. -> allocate memory for response (must be freed afterwards with free2() if != NULL).

◆ sock_error_message()

const char* sock_error_message ( )

...