mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
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:
committed by
GitHub
parent
54b110a367
commit
c10d449e43
19
test/unit/stdlib/net/tcp_socketpair.c3
Normal file
19
test/unit/stdlib/net/tcp_socketpair.c3
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user