☰
net
fuzion.sys.net
accept a new connection for given socket descriptor.
may block until there is a connection to accept.
returns a new / different descriptor which
corresponds to the accepted connection only.
true => arr_result[0] is the socket descriptor
false => arr_result[0] is an error number
may block until there is a connection to accept.
returns a new / different descriptor which
corresponds to the accepted connection only.
true => arr_result[0] is the socket descriptor
false => arr_result[0] is an error number
accept a new connection for given socket descriptor, wrapper for accept intrinsic.
returns an error or a new descriptor.
returns an error or a new descriptor.
bind a name to a newly created socket, wrapper for bind0 intrinsic
bind a name to a newly created socket
0 => arr_result[0] is the socket descriptor
-1 => arr_result[0] is an error number
0 => arr_result[0] is the socket descriptor
-1 => arr_result[0] is an error number
open and connect a client socket
open and connect a client socket
0 => arr_result[0] is the socket descriptor
-1 => arr_result[0] is an error number
0 => arr_result[0] is the socket descriptor
-1 => arr_result[0] is an error number
activates a server socket, setting a backlog
of a maximum amount of connections which are kept
waiting for acceptance.
returns zero on success, anything else is an error.
of a maximum amount of connections which are kept
waiting for acceptance.
returns zero on success, anything else is an error.
read a maximum of max_bytes from descriptor, wrapper for read intrinsic
may block if descriptor is set to blocking.
may block if descriptor is set to blocking.
read bytes into arr_data buffer
true => arr_result[0] is the number of bytes read
false => arr_result[0] is an error number
true => arr_result[0] is the number of bytes read
false => arr_result[0] is an error number
set descriptor to blocking / none blocking mode.
0 = blocking, 1 = none_blocking
returns zero on success, anything else is an error.
NYI non blocking needs some kind of polling mechanism like epoll / kqueue
probably not good enough:
- select "can monitor only file descriptors numbers
- poll is in O(n)
difficult to implement on windows, read here: https://notgull.github.io/device-afd/
returns zero on success, anything else is an error.
NYI non blocking needs some kind of polling mechanism like epoll / kqueue
probably not good enough:
- select "can monitor only file descriptors numbers
- poll is in O(n)
difficult to implement on windows, read here: https://notgull.github.io/device-afd/
write data to descriptor, wrapper for write intrinsic
may block if descriptor is set to blocking.
may block if descriptor is set to blocking.
internally this builds on:
- java: nio
- why not java.net.Socket etc.?: this is only suitable for blocking I/O
- why not nio2? : nio2 is basically the same as nio but asynchronous.
- c/posix: posix-sockets
- c/win: winsock2
sources of inspiration:
- https://github.com/tezc/sc/
- https://github.com/jart/cosmopolitan
- https://learn.microsoft.com/en-us/windows/win32/winsock/complete-server-code
- https://learn.microsoft.com/en-us/windows/win32/winsock/complete-client-code
NYI: use error codes coming from backend