#include "../include/CL.h"
#include "../include/command.h"
#include "../include/utility.h"
#include "../include/cond_comp.h"
#include <netdb.h>
#include <fcntl.h>
#include <arpa/inet.h>
#include <cstdlib>
#include <cstring>
Go to the source code of this file.
Functions | |
int | send_end_command (int sock, string file_name, string CL_address) |
function to notify the end of transfer to the DFR | |
FS_info_struct * | get_FS_info (const char *mes) |
response data parser | |
int | transfer_file (int FS_sd, string file_name, string new_file_name, string CL_address) |
function to transfer a file from a FS | |
int | main (int argc, char *argv[]) |
FS_info_struct* get_FS_info | ( | const char * | mes | ) |
response data parser
when a clients asks for a file or asks for a notification, the DFR may allocate to the client the file it was looking for... in this case, in the response message, some info about how to reach the FS may be included in the response, and are transferred as a single string <FS_ip_address:FS_port> this function fills a FS_info_struct using the mes string passed as a parameter
mes | | char array to parse |
Definition at line 37 of file CL.cpp.
References FS_info_struct::ip_address, and FS_info_struct::port.
int main | ( | int | argc, | |
char * | argv[] | |||
) |
int send_end_command | ( | int | sock, | |
string | file_name, | |||
string | CL_address | |||
) |
function to notify the end of transfer to the DFR
it is used to send the end_file_transfer command to the DFR after transfer completion.
sock | | socket connected to the DFR | |
file_name | | file to release | |
CL_address | | address and port string identifying the caller |
Definition at line 13 of file CL.cpp.
References end_file_transfer, ERR_NO_TRANSFER, LOG, OK, and send_command().
int transfer_file | ( | int | FS_sd, | |
string | file_name, | |||
string | new_file_name, | |||
string | CL_address | |||
) |
function to transfer a file from a FS
it is used to send a command to a FS to obtain a file it holds
FS_sd | | working socket descriptor connected to the listening FS | |
file_name | | name of the file on the FS that the caller wants to transfer | |
new_file_name | | name of the new file created on the caller side after transfer | |
CL_address | | address and port string identifying the caller |
Definition at line 62 of file CL.cpp.
References ERR_FILE_NOT_EXISTS, ERR_TOO_MANY_CLIENTS, get_file, LOG, OK, and send_command().