forked from yliu634/smash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestSocket.cpp
More file actions
44 lines (31 loc) · 778 Bytes
/
testSocket.cpp
File metadata and controls
44 lines (31 loc) · 778 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
39
40
41
42
43
44
#pragma once
#include "common.h"
#include "Smash/socket_node.h"
typedef string K;
typedef string V;
int main() {
commonInit();
SocketNode a, b;
a.name = "a";
b.name = "b";
a.initSocket(8080);
b.initSocket();
cout.flush();
char messages[][6] = {{1, 2, 3, 4, 5, 6},
{6, 5, 4, 3, 2, 1}};
int fd = b.connectToServer("localhost:8080");
b.my_write(fd, 0, messages[0], 6);
b.my_write(fd, 1, messages[1], 6);
vector<char> longMessage;
int n = 4096 * 2 + 3;
longMessage.resize(n);
for (int i = 0; i < n; ++i) {
int c = i & 255;
if (c == 0) c = (i / 255) & 255;
longMessage[i] = c;
}
b.my_write(fd, 2, longMessage.data(), n);
close(fd);
this_thread::sleep_for(2s);
return 0;
}