-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.c
54 lines (40 loc) · 1.09 KB
/
client.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include "sockets.h"
int main( int argc, char *argv[] ) {
clientSocket cSocket;
destSpec dest;
userOpts option = OPT_NOSELECTION;
unsigned char data[MAXDATASIZE];
size_t dataLen;
//processInputParams( argc, argv, dest );
dest.addr = "127.0.0.1";
dest.port = "3000";
// printf( "Here\n" );
if( clientConnect( &cSocket, &dest ) == -1 ) {
perror( "clientConnect" );
return 1;
}
// printf( "Here2\n" );
while( option != OPT_QUIT ) {
//Do stuff
if( option != OPT_NOSELECTION ) {
if( clientSendOpt( &cSocket, option, data, dataLen ) == -1 ) {
perror( "clientSendOpt" );
return 1;
}
}
if( option == OPT_RECV ) {
if( clientWaitForFile( &cSocket, data, dataLen ) == -1 ) { //Wait for the server's response, store it in the filename still specified in data
perror( "ClientWaitForFile Error" );
}
}
if( queryUser( &option, data, MAXDATASIZE, &dataLen ) == -1 ) {
perror( "queryUser" );
return 1;
}
}
// printf( "Here3\n" );
clientSendOpt( &cSocket, option, NULL, 0 ); //Let the server know
clientDisconnect( &cSocket );
return 0;
}