Add local TcpSocketPair (#2526)

* Add extern fn socketpair() to posix
* Add extern fn getsockname() for local socketpair loopback in windows
* Add local TcpSocketPair
* Add unit test for TcpSocketPair
* Add implicit wsa startup

---------

Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
Christopher Coverdale
2025-10-27 12:16:14 +00:00
committed by GitHub
parent 54b110a367
commit c10d449e43
6 changed files with 133 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
module tcpsockpairtest @test;
import std::net;
fn void test_tcp_sock_pair()
{
tcp::TcpSocketPair sockets;
sockets.init()!!;
defer sockets.destroy()!!;
String expected = "hello, world!";
sockets.send.write(expected)!!;
char[100] recv_buf;
sockets.recv.read(&recv_buf)!!;
String result = (String) recv_buf[0:expected.len];
assert(result.trim() == expected);
}