mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
* 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>
20 lines
372 B
Plaintext
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);
|
|
}
|