15#ifndef SOCKET_COMMON_H
16#define SOCKET_COMMON_H
26#ifndef NUMBER_OF_FEDERATES
27#define NUMBER_OF_FEDERATES 1
36#define DELAY_BETWEEN_SOCKET_RETRIES MSEC(100)
44#define TCP_TIMEOUT_TIME SEC(10)
52#define UDP_TIMEOUT_TIME SEC(1)
58#define CONNECT_RETRY_INTERVAL MSEC(500)
67#define CONNECT_TIMEOUT MINUTES(1)
76#define MAX_NUM_PORT_ADDRESSES 16u
87#define PORT_BIND_RETRY_INTERVAL SEC(1)
93#define PORT_BIND_RETRY_LIMIT 60
103#define DEFAULT_PORT 15045u
109#define MSG_TYPE_FAILED 25
150 bool increment_port_on_retry);
int create_real_time_tcp_socket_errexit()
Create an IPv4 TCP socket with Nagle's algorithm disabled.
int shutdown_socket(int *socket, bool read_before_closing)
Shutdown and close the socket.
int accept_socket(int socket, int rti_socket)
Wait for an incoming connection request on the specified server socket.
void read_from_socket_fail_on_error(int *socket, size_t num_bytes, unsigned char *buffer, char *format,...)
Read the specified number of bytes from the specified socket into the specified buffer and close the ...
socket_type_t
Type of socket.
Definition socket_common.h:115
int connect_to_socket(int sock, const char *hostname, int port)
Attempt to establish a TCP connection to the specified hostname and port.
int read_from_socket_close_on_error(int *socket, size_t num_bytes, unsigned char *buffer)
Read the specified number of bytes from the specified socket into the specified buffer.
int create_server(uint16_t port, int *final_socket, uint16_t *final_port, socket_type_t sock_type, bool increment_port_on_retry)
Create a TCP server that listens for socket connections.
int read_from_socket(int socket, size_t num_bytes, unsigned char *buffer)
Read the specified number of bytes from the specified socket into the specified buffer.
void write_to_socket_fail_on_error(int *socket, size_t num_bytes, unsigned char *buffer, lf_mutex_t *mutex, char *format,...)
Write the specified number of bytes to the specified socket.
void init_shutdown_mutex(void)
Initialize shutdown mutex.
ssize_t peek_from_socket(int socket, unsigned char *result)
Without blocking, peek at the specified socket.
int write_to_socket(int socket, size_t num_bytes, unsigned char *buffer)
Write the specified number of bytes to the specified socket from the specified buffer.
int write_to_socket_close_on_error(int *socket, size_t num_bytes, unsigned char *buffer)
Write the specified number of bytes to the specified socket.
@ TCP
Definition socket_common.h:115
@ UDP
Definition socket_common.h:115