blob: 3f5038b9efc73eb19c0632daefb8d9838ef08889 (
plain)
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
|
#include "connection.h"
void _waitForLength( Connection &con, int len)
{
int rlen = con.getInputAmnt();
if (rlen >= len)
return;
int time_left = 5;
int mic_left = 0;
while (rlen < len)
{
if (time_left == 0 && mic_left == 0)
{
throw "Socket Timeout";
}
con.readInput(time_left, mic_left, &time_left, &mic_left);
rlen = con.getInputAmnt();
}
}
int main()
{
Connection c;
c.open("localhost", 4001 );
c.appendOutput("d");
c.writeOutput();
_waitForLength( c, 40 );
c.close();
return 0;
}
|