Files
c3c/test/unit/stdlib/net/tcp_socketpair.c3
Christopher Coverdale c10d449e43 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>
2025-10-27 13:16:14 +01:00

20 lines
372 B
Plaintext

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);
}