Skip to content

Commit

Permalink
Merge branch 'refactor-only-comm-type' of github.com:lf-lang/reactor-…
Browse files Browse the repository at this point in the history
…c into refactor-only-comm-type
  • Loading branch information
Jakio815 committed Dec 26, 2024
2 parents b2a5af8 + 9b8b7d6 commit 92fd156
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions include/core/federated/network/socket_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#define SOCKET_COMMON_H

#include "low_level_platform.h"
#define NUM_SOCKET_RETRIES 10

/**
* The amount of time to wait after a failed socket read or write before trying again. This defaults to 100 ms.
*/
#define DELAY_BETWEEN_SOCKET_RETRIES MSEC(100)

/**
Expand Down Expand Up @@ -102,11 +105,15 @@ int create_real_time_tcp_socket_errexit();
int create_server(uint16_t port, int* final_socket, uint16_t* final_port, socket_type_t sock_type, bool increment_port_on_retry);

/**
* These two functions waits for an incoming connection request on the specified server socket.
* It blocks until a connection is successfully accepted. If an error occurs that is not
* Wait for an incoming connection request on the specified server socket.
* This blocks until a connection is successfully accepted. If an error occurs that is not
* temporary (e.g., `EAGAIN` or `EWOULDBLOCK`), it reports the error and exits. Temporary
* errors cause the function to retry accepting the connection.
* If the rti_socket is not -1, it checks if the RTI's server socket is still open.
*
* If the `rti_socket` is not -1, this function checks whether the specified socket is still open.
* If it is not open, then this function returns -1.
* This is useful for federates to determine whether they are still connected to the federation
* and to stop waiting when they are not.
*
* @param socket The server socket file descriptor that is listening for incoming connections.
* @param rti_socket The rti socket for the federate to check if it is still open.
Expand All @@ -118,8 +125,8 @@ int accept_socket(int socket, int rti_socket);

/**
*
* This function attempts to establish a TCP connection to the specified hostname
* and port. It uses `getaddrinfo` to resolve the hostname and retries the connection
* Attempt to establish a TCP connection to the specified hostname
* and port. This function uses `getaddrinfo` to resolve the hostname and retries the connection
* periodically if it fails. If the specified port is 0, it iterates through a range
* of default ports starting from `DEFAULT_PORT`. The function will stop retrying
* if the `CONNECT_TIMEOUT` is reached.
Expand Down

0 comments on commit 92fd156

Please # to comment.