-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
26 lines (19 loc) · 677 Bytes
/
test.cpp
File metadata and controls
26 lines (19 loc) · 677 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
#include "tcp.h"
#include <vector>
#include <iostream>
using std::vector;
int main(void) {
string sBuf;
_TCPSocket ts = CreateTCPServer(18502); // Allocate TCPServer object that have a socket.
_TCPSocket tc = CreateTCPClient((IP_ADDR)LOCALHOST, 18502); // Allocate TCPClient object that have a socket.
ts.SetOption(Linger); // New version
// ts.SetOption(SOL_SOCKET, SO_LINGER); // Option Setting. old version
ts.Operate(); // listen.
std::cout << "Send Test" << std::endl;
ts << "123"; // Send.
std::cout << "Recv Test" << std::endl;
ts >> sBuf; // Receive
std::cout << sBuf << std::endl;
ts.Close();
return 0;
}