-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserver.cpp
More file actions
31 lines (27 loc) · 994 Bytes
/
server.cpp
File metadata and controls
31 lines (27 loc) · 994 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
#include "RDMAServerSocket.h"
#include <iostream>
#include <stdlib.h>
int main(int argc, char* argv[])
{
try {
rdma::ServerSocket serverSocket(argv[1], argv[2], atoi(argv[3]), atoi(argv[4]));
while(1) {
rdma::ClientSocket* clientSocket = serverSocket.accept();
try {
while(1) {
rdma::Buffer readPacket = clientSocket->read();
rdma::Buffer sendPacket = clientSocket->getWriteBuffer();
memcpy(sendPacket.get(), readPacket.get(), readPacket.size);
clientSocket->write(sendPacket);
clientSocket->returnReadBuffer(readPacket);
}
} catch(std::exception& e) {
std::cerr << "client exception: " << e.what() << std::endl;
}
delete clientSocket;
}
} catch(std::exception& e) {
std::cerr << "exception: " << e.what() << std::endl;
}
return 0;
}