mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
std/lib/net/os: add bind, listen and accept for posix platforms
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
committed by
Christoffer Lerno
parent
97ded16ea2
commit
df9bc377dd
@@ -9,6 +9,9 @@ def NativeSocket = distinct inline Fd;
|
|||||||
extern fn CInt connect(NativeSocket socket, SockAddrPtr address, Socklen_t address_len);
|
extern fn CInt connect(NativeSocket socket, SockAddrPtr address, Socklen_t address_len);
|
||||||
extern fn NativeSocket socket(CInt af, CInt type, CInt protocol) @extern("socket");
|
extern fn NativeSocket socket(CInt af, CInt type, CInt protocol) @extern("socket");
|
||||||
extern fn int fcntl(NativeSocket socket, int cmd, ...) @extern("fcntl");
|
extern fn int fcntl(NativeSocket socket, int cmd, ...) @extern("fcntl");
|
||||||
|
extern fn CInt bind(NativeSocket socket, SockAddrPtr address, Socklen_t address_len) @extern("bind");
|
||||||
|
extern fn CInt listen(NativeSocket socket, CInt backlog) @extern("listen");
|
||||||
|
extern fn NativeSocket accept(NativeSocket socket, SockAddrPtr address, Socklen_t* address_len) @extern("accept");
|
||||||
|
|
||||||
macro void! NativeSocket.close(NativeSocket this)
|
macro void! NativeSocket.close(NativeSocket this)
|
||||||
{
|
{
|
||||||
@@ -32,4 +35,4 @@ macro void! NativeSocket.set_non_blocking(NativeSocket this)
|
|||||||
macro bool NativeSocket.is_non_blocking(NativeSocket this)
|
macro bool NativeSocket.is_non_blocking(NativeSocket this)
|
||||||
{
|
{
|
||||||
return fcntl(this, F_GETFL, 0) & O_NONBLOCK == O_NONBLOCK;
|
return fcntl(this, F_GETFL, 0) & O_NONBLOCK == O_NONBLOCK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user