forked from Rodrig79/Project-3-A-Simple-Network-File-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.cpp
More file actions
38 lines (29 loc) · 956 Bytes
/
server.cpp
File metadata and controls
38 lines (29 loc) · 956 Bytes
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
#include <iostream>
#include <string>
#include <cstdlib>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include "FileSys.h"
using namespace std;
int main(int argc, char* argv[]) {
if (argc < 2) {
cout << "Usage: ./nfsserver port#\n";
return -1;
}
int port = atoi(argv[1]);
//networking part: create the socket and accept the client connection
int sock; //change this line when necessary!
//mount the file system
FileSys fs;
fs.mount(sock); //assume that sock is the new socket created
//for a TCP connection between the client and the server.
//loop: get the command from the client and invoke the file
//system operation which returns the results or error messages back to the clinet
//until the client closes the TCP connection.
//close the listening socket
//unmout the file system
fs.unmount();
return 0;
}