-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzz.cpp
41 lines (34 loc) · 839 Bytes
/
zz.cpp
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
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "p/base/endpoint.h"
#include "p/base/socket.h"
#include <string>
char buf[10240001];
int main() {
p::base::EndPoint tmp(nullptr, 9099);
p::base::Socket x;
int ret = x.Listen(tmp);
printf("Listen ret=%s\n", strerror(ret));
p::base::Socket s;
ret = x.Accept(&s);
if (ret) {
printf("Accept failed,%s\n", strerror(ret));
} else {
printf("accpet succsse\n");
sleep(3);
ssize_t len = s.Read(buf, 10240000);
printf("%ld\n", len);
}
while (true) {
sleep(5);
ssize_t len = s.Read(buf, 10240000);
if (len >= 0) {
printf("%ld\n", len);
} else {
printf("Read Error,%s\n", strerror(len));
}
}
return 0;
}