include/CL.h File Reference

#include <string>

Include dependency graph for CL.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FS_info_struct
 info on a FS More...

Functions

FS_info_structget_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 send_end_command (int sock, string file_name, string CL_address)
 function to notify the end of transfer to the DFR
void mode_1 (int sock, string file_name, string new_file_name, int delay)
 mode 1 execution
void mode_2 (int sock, string file_name, string new_file_name, int delay)
 mode 2 execution
int main (int argc, char *argv[])


Detailed Description

this file defines the CLs main() function which contains the code for a test client. the test client has no user interface and it's behaviour can be configured only using parameters from the command line

USAGE:

 CL [DFR_IP_address_or_domain_name_for_CLs] [DFR_port_for_CLs] \
         [file_to_transfer] [new_filename] [mode] [delay]
 

mode is an integer, it's defined values are the following:

delay enables the programmer to test the DFR better, it is used only if the TEST macro has been defined in compilation phase, but must be always provided from the command line

Definition in file CL.h.


Function Documentation

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

Parameters:
mes | char array to parse
Returns:
the new FS_info_struct containing FS parameters (allocated dynamically) or NULL if some error was detected

Definition at line 37 of file CL.cpp.

References FS_info_struct::ip_address, and FS_info_struct::port.

Referenced by mode_1(), and mode_2().

int main ( int  argc,
char *  argv[] 
)

Definition at line 116 of file CL.cpp.

void mode_1 ( int  sock,
string  file_name,
string  new_file_name,
int  delay 
)

mode 1 execution

the client will request a start_file_transfer on the specified file, transfer the file, and signal the end of transfer... all of this will happen in an infinite cycle, so the client will need to be interrupted manually (if no error occours)

Parameters:
sock | socket of the client connected to the DFR
file_name | the file the client wants from a FS
new_file_name | the future name of the obtained file
delay | this enables the programmer to test the DFR better, it is used only if the TEST macro has been defined in compilation phase, but must be always specified

Definition at line 9 of file CL_mode_1.cpp.

References ERR_FILE_NOT_EXISTS, ERR_TOO_MANY_CLIENTS, get_FS_info(), init_sd_cli(), INT_AS_STRING_BYTES, FS_info_struct::ip_address, LOG, OK, FS_info_struct::port, send_command(), send_end_command(), start_file_transfer, and transfer_file().

Referenced by main().

void mode_2 ( int  sock,
string  file_name,
string  new_file_name,
int  delay 
)

mode 2 execution

the client will request a reg_notification on the specified file... when will be notified, will try to transfer the file, this will happen until the file is successfully transfered, at the end of transfer an end_file_transfer message will be sent to the DF

Parameters:
sock | socket of the client connected to the DFR
file_name | the file the client wants from a FS
new_file_name | the future name of the obtained file
delay | this enables the programmer to test the DFR better, it is used only if the TEST macro has been defined in compilation phase, but must be always specified

Definition at line 9 of file CL_mode_2.cpp.

References ERR_FILE_NOT_EXISTS, ERR_NO_NOTIFICATION, ERR_TOO_MANY_CLIENTS, get_FS_info(), init_sd_cli(), INT_AS_STRING_BYTES, FS_info_struct::ip_address, LOG, notify, OK, FS_info_struct::port, receive_command(), receive_sft_reply(), reg_notification, reply_command(), send_command(), send_end_command(), and transfer_file().

Referenced by main().

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.

Parameters:
sock | socket connected to the DFR
file_name | file to release
CL_address | address and port string identifying the caller
Returns:
0 on success, 1 on minor error, -1 on bad on error

Definition at line 13 of file CL.cpp.

References end_file_transfer, ERR_NO_TRANSFER, LOG, OK, and send_command().

Referenced by mode_1(), and mode_2().

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

Parameters:
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
Returns:
0 on success, 1 on minor error, -1 on bad on error

Definition at line 62 of file CL.cpp.

References ERR_FILE_NOT_EXISTS, ERR_TOO_MANY_CLIENTS, get_file, LOG, OK, and send_command().

Referenced by mode_1(), and mode_2().


Generated on Sat Jun 13 21:06:30 2009 for DistributedFileRepository by  doxygen 1.5.8