reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
socket_common.h
Go to the documentation of this file.
1#ifndef SOCKET_COMMON_H
2#define SOCKET_COMMON_H
3
5
9#define DELAY_BETWEEN_SOCKET_RETRIES MSEC(100)
10
15#define TCP_TIMEOUT_TIME SEC(10)
16
21#define UDP_TIMEOUT_TIME SEC(1)
22
26#define CONNECT_RETRY_INTERVAL MSEC(500)
27
33#define CONNECT_TIMEOUT MINUTES(1)
34
40#define MAX_NUM_PORT_ADDRESSES 16u
41
49#define PORT_BIND_RETRY_INTERVAL SEC(1)
50
54#define PORT_BIND_RETRY_LIMIT 60
55
62#define DEFAULT_PORT 15045u
63
67#define MSG_TYPE_FAILED 25
68
70
75
84
105int create_server(uint16_t port, int* final_socket, uint16_t* final_port, socket_type_t sock_type,
106 bool increment_port_on_retry);
107
125int accept_socket(int socket, int rti_socket);
126
140int connect_to_socket(int sock, const char* hostname, int port);
141
156int read_from_socket(int socket, size_t num_bytes, unsigned char* buffer);
157
167int read_from_socket_close_on_error(int* socket, size_t num_bytes, unsigned char* buffer);
168
185void read_from_socket_fail_on_error(int* socket, size_t num_bytes, unsigned char* buffer, lf_mutex_t* mutex,
186 char* format, ...);
187
196ssize_t peek_from_socket(int socket, unsigned char* result);
197
212int write_to_socket(int socket, size_t num_bytes, unsigned char* buffer);
213
223int write_to_socket_close_on_error(int* socket, size_t num_bytes, unsigned char* buffer);
224
240void write_to_socket_fail_on_error(int* socket, size_t num_bytes, unsigned char* buffer, lf_mutex_t* mutex,
241 char* format, ...);
242
243#endif /* SOCKET_COMMON_H */
void * lf_mutex_t
Definition lf_arduino_support.h:118
Platform API support for the C target of Lingua Franca.
int create_real_time_tcp_socket_errexit()
Create an IPv4 TCP socket with Nagle's algorithm disabled (TCP_NODELAY) and Delayed ACKs disabled (TC...
Definition socket_common.c:27
int accept_socket(int socket, int rti_socket)
Definition socket_common.c:187
socket_type_t
Definition socket_common.h:69
@ TCP
Definition socket_common.h:69
@ UDP
Definition socket_common.h:69
int connect_to_socket(int sock, const char *hostname, int port)
Definition socket_common.c:219
int read_from_socket_close_on_error(int *socket, size_t num_bytes, unsigned char *buffer)
Definition socket_common.c:301
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.
Definition socket_common.c:136
int read_from_socket(int socket, size_t num_bytes, unsigned char *buffer)
Definition socket_common.c:273
void read_from_socket_fail_on_error(int *socket, size_t num_bytes, unsigned char *buffer, lf_mutex_t *mutex, char *format,...)
Definition socket_common.c:317
void write_to_socket_fail_on_error(int *socket, size_t num_bytes, unsigned char *buffer, lf_mutex_t *mutex, char *format,...)
Definition socket_common.c:386
lf_mutex_t socket_mutex
Definition socket_common.c:25
ssize_t peek_from_socket(int socket, unsigned char *result)
Definition socket_common.c:337
int write_to_socket(int socket, size_t num_bytes, unsigned char *buffer)
Definition socket_common.c:345
int write_to_socket_close_on_error(int *socket, size_t num_bytes, unsigned char *buffer)
Definition socket_common.c:371
char buffer[BUFFER_SIZE]
Definition trace_util.c:42