mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-14 23:16:55 -04:00
Start implementation of TCP server
This commit is contained in:
parent
4d39ee28a4
commit
72a8fd2f37
@ -167,6 +167,18 @@ int netcat_udp_client(const tlib::ip::address& server, size_t port){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int netcat_tcp_server(const tlib::ip::address& local, size_t port){
|
int netcat_tcp_server(const tlib::ip::address& local, size_t port){
|
||||||
|
auto ip_str = ip_to_str(local);
|
||||||
|
tlib::printf("netcat TCP server %s:%u\n", ip_str.c_str(), port);
|
||||||
|
|
||||||
|
tlib::socket sock(tlib::socket_domain::AF_INET, tlib::socket_type::STREAM, tlib::socket_protocol::TCP);
|
||||||
|
|
||||||
|
sock.server_start(local, port);
|
||||||
|
|
||||||
|
if (!sock) {
|
||||||
|
tlib::printf("nc: socket error: %s\n", std::error_message(sock.error()));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user