#include "../include/command.h"#include <cstdlib>#include <cstring>
Go to the source code of this file.
Functions | |
| int | send_command (int sock, command com, int *rep_data_size, char **rep_data) |
| sends a synchronized command | |
| int | receive_command (int sock, command *com) |
| receives a synchronized command | |
| int | reply_command (int sock, int status, int add_bytes, const char *add_data) |
| sends a response message to a previously received command | |
| int | receive_sft_reply (int sock, int *rep_data_size, char **rep_data) |
| receives a response message | |
| int receive_command | ( | int | sock, | |
| command * | com | |||
| ) |
receives a synchronized command
receive_command() is declared friend to allow use of fill_from_string() private member function
| sock | | socket from which to receive the command | |
| com | | command object to be filled for the caller |
Definition at line 161 of file command.cpp.
References command::fill_from_string().
Referenced by CL_req_s_body(), FS_req_s_body(), mode_2(), and req_server().
| int receive_sft_reply | ( | int | sock, | |
| int * | rep_data_size, | |||
| char ** | rep_data | |||
| ) |
receives a response message
this function SHOULD be used only by the CLs, when they ask a notification and the DFR finally signals the disponibility of the file to the client, the server sends a notify command to the client. If the client replies to this message with an OK status, the server assumes that a start_file_transfer command has been initiated by the client, this means that the DFR will reply with a start_file_transfer response message. the CL can use this function to catch that response message.
| sock | | socket on which the CL wants to wait for the response | |
| rep_data | | pointer to data to be returned to the client (allocated dynamically) | |
| rep_data_size | | pointer to an integer to return the size of the rep_data |
Definition at line 213 of file command.cpp.
References ERR_UNKNOWN.
Referenced by mode_2().
| int reply_command | ( | int | sock, | |
| int | status, | |||
| int | add_bytes, | |||
| const char * | add_data | |||
| ) |
sends a response message to a previously received command
each command needs a response message, allowing the corresponding send_command() call to return to the caller. the reply message is built as follows:
<status_integer|size_of_additional_data|additional_data>
status_integer is one of the following values:
size_of_additional_data is an integer-as-string field which is the number of bytes in the following field.
additional_data is the data the responder is sending to the commander which has previously sent a command.
| sock | | socket to send the response message | |
| status | | status of the request, as described above | |
| add_bytes | | number of bytes to be sent as additional data (0 if no additional data) | |
| add_data | | pointer to additional data to be sent (NULL if no additional data) |
Definition at line 178 of file command.cpp.
References INT_AS_STRING_BYTES.
Referenced by FS_req_s_body(), mode_2(), req_server(), serve_end_file_transfer(), serve_reg_notification(), and serve_start_file_transfer().
| int send_command | ( | int | sock, | |
| command | com, | |||
| int * | rep_data_size, | |||
| char ** | rep_data | |||
| ) |
sends a synchronized command
send_command() is declared friend to allow use of to_string() private member function
the response data will be one of the following, depending on the command:
| sock | | socket to contact the opposite end of the channel | |
| com | | command to be sent | |
| rep_data | | pointer to data to be returned to the caller (allocated dynamically) | |
| rep_data_size | | pointer to an integer to return the size of the rep_data, if any |
Definition at line 112 of file command.cpp.
References ERR_UNKNOWN, and command::to_string().
Referenced by main(), mode_1(), mode_2(), send_end_command(), serve_reg_notification(), and transfer_file().
1.5.8