-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.cpp
More file actions
59 lines (39 loc) · 1.31 KB
/
server.cpp
File metadata and controls
59 lines (39 loc) · 1.31 KB
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
55
56
57
58
59
#include "server.h"
#include "proxy.h"
using namespace std;
Server::Server(int port, string folder) {
this->port = port;
this->folder = folder;
}
Server::~Server() {
}
void Server::Run() {
cout << "running away" << endl;
Proxy proxy;
int server = proxy.create_server_socket(port);
while(true){
//1. Await connection
int client_socket;
struct sockaddr_in client;
socklen_t alen = sizeof(struct sockaddr_in);
cout << "server ip: " << proxy.get_ip() << endl;
cout << "accepting client" << endl;
if ((client_socket = accept(server, (struct sockaddr *)&client, &alen)) < 0) {
cerr << "Accept failed" << endl;
exit(1);
}
//2. receive connection,
cout << "idk somethings fucky" << endl;
char* message;
proxy.receive_from_socket(client_socket, message);
cout << message << endl;
//2.1 make TCB object,
//2.2 create segment object from void* received from client,
//3. Handshake
}
//4. After estab Open File Based on connectors IP and port
//5. Create and populate new segment to be sent to client
//6. Send segment to client
//7. Go to 1.
//I feel like 2 - 6 could be compartmentalized and maybe even parallellized, but idk
}