Add set_blocking for network sockets

This commit is contained in:
Sokus
2023-03-08 13:30:12 +01:00
parent a262c0bbf3
commit 1ecab2fcbc
10 changed files with 89 additions and 0 deletions
+13
View File
@@ -225,6 +225,11 @@ TCP_CORK: int : 3
MSG_TRUNC : int : 0x20
// TODO: add remaining fcntl commands
// reference: https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/fcntl.h
F_GETFL: int : 3 /* Get file flags */
F_SETFL: int : 4 /* Set file flags */
// NOTE(zangent): These are OS specific!
// Do not mix these up!
RTLD_LAZY :: 0x001
@@ -1074,3 +1079,11 @@ shutdown :: proc(sd: Socket, how: int) -> (Errno) {
}
return ERROR_NONE
}
fcntl :: proc(fd: int, cmd: int, arg: int) -> (int, Errno) {
result := unix.sys_fcntl(fd, cmd, arg)
if result < 0 {
return 0, _get_errno(result)
}
return result, ERROR_NONE
}