You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @brief class that handles a single point to point server client connection, emulating the server side.
15
-
*
16
-
* The flow of this class goes as follows:
17
-
*
18
-
* 1. When the constructor is called, the listener is activated and starts working immediately
19
-
*
20
-
* 2. After a client issues a connection to the ServerSocket and Ethernet#update is executed, the ServerSocket accepts the request
21
-
*
22
-
* 3. Accepting the request raises an interrupt that calls accept_callback, which closes the listener socket (on server_control_block) and opens the connection socket (on client_control_block)
23
-
*
24
-
* 4. The connection goes on until one of the ends closes it, which calls the ErrorHandler to send the board into fault as a default behaviour.
* @brief ServerSocket constructor that uses the EthernetNode class as a parameter
80
-
*
81
-
* @param local_node the EthernetNode to listen to
82
-
*
83
-
* @see EthernetNode
84
-
*/
85
-
ServerSocket(EthernetNode local_node);
86
-
~ServerSocket();
87
-
88
-
voidoperator=(ServerSocket&& other);
89
-
90
-
/**
91
-
* @brief ends the connection between the server and the client.
92
-
*/
93
-
voidclose();
94
-
/**
95
-
* @brief saves the order data into the tx_packet_buffer so it can be sent when a connection is accepted
96
-
*
97
-
* @param order the order to send, which contains the data and id of the message
98
-
* @return true if the data could be allocated in the buffer, false otherwise
99
-
*/
100
-
booladd_order_to_queue(Order& order);
101
-
102
-
/**
103
-
* @brief puts the order data into the tx_packet_buffer and sends all the data in the buffer to the client
104
-
*
105
-
* @param order the order to send, which contains the data and id of the message
106
-
* @return true if the data was sent successfully, false otherwise
107
-
*/
108
-
boolsend_order(Order& order) override{
109
-
if(state != ACCEPTED){
110
-
returnfalse;
111
-
}
112
-
tx_packet_buffer.push(&order);
113
-
send();
114
-
returntrue;
115
-
}
116
-
117
-
/**
118
-
* @brief sends all the binary data saved in the tx_packet_buffer to the connected client.
119
-
*
120
-
* This function is the one that actually handles outgoing communication, sending one by one the packets in the tx_packet_buffer
121
-
* The messages in the buffer are all immediately sent after calling this function, unless an error of any kind happened, in which case ErrorHandler is raised
122
-
*/
123
-
voidsend();
124
-
125
-
/**
126
-
* @brief function that returns wether or not a client is connected to the ServerSocket
127
-
*
128
-
* This functions returns a comparison to the state of the ServerSocket, checking wether or not it is on the ACCEPTED state
129
-
* This function is equivalent to doing instance->state == ServerSocket#ACCEPT
130
-
*
131
-
* @return true if a connection with the client was established, false otherwise
0 commit comments