-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRDMAClientSocket.h
68 lines (49 loc) · 1.15 KB
/
RDMAClientSocket.h
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
60
61
62
63
64
65
66
67
#pragma once
#include <boost/noncopyable.hpp>
#include <boost/circular_buffer.hpp>
#include <string>
#include <stdint.h>
#include <rdma/rdma_cma.h>
#include <rdma/rdma_verbs.h>
namespace rdma
{
std::string getLastErrorMessage();
class ClientSocket;
class Buffer
{
friend class ClientSocket;
public:
Buffer()
: buffer(NULL), size(0)
{}
void* get()
{
return buffer;
}
size_t size;
private:
Buffer(void* buffer, size_t size)
: buffer(buffer), size(size)
{}
void* buffer;
};
class ClientSocket : boost::noncopyable
{
public:
ClientSocket(const char* host, const char* port, uint32_t packetSize, uint32_t packetWindowSize);
ClientSocket(struct rdma_cm_id* clientId, uint32_t packetSize, uint32_t packetWindowSize);
~ClientSocket();
Buffer getWriteBuffer();
void write(const Buffer& buffer);
Buffer read();
void returnReadBuffer(const Buffer& buffer);
private:
void setupBuffers();
struct rdma_cm_id* clientId;
struct ibv_mr* memoryRegion;
uint32_t packetSize;
uint32_t packetWindowSize;
char* buffer;
boost::circular_buffer<Buffer> writeBuffers;
};
};