KolibriOS kernel
socket.inc File Reference

Classes

struct  SOCKET
 
struct  IP_SOCKET
 
struct  TCP_SOCKET
 
struct  UDP_SOCKET
 
struct  RING_BUFFER
 
struct  STREAM_SOCKET
 
struct  sockaddr
 
struct  socket_queue_entry
 
struct  socket_options
 

Macros

#define socket_init
 --------------------------------------------------------------—; ; socket_init ; ; --------------------------------------------------------------—; More...
 

Variables

rd net_sockets
 
dd last_socket_num
 
dw last_UDP_port
 last used ephemeral port More...
 
dw last_TCP_port
 
MUTEX socket_mutex
 
label sys_socket
 --------------------------------------------------------------—; ; Sockets API (system function 75) ; ; --------------------------------------------------------------—; More...
 
label socket_open
 --------------------------------------------------------------—; ; socket_open: Create a new socket. ; ; IN: ecx = domain ; edx = type ; esi = protocol ; ; OUT: eax = socket number ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label socket_bind
 --------------------------------------------------------------—; ; socket_bind: Bind to a local port. ; ; IN: ecx = socket number ; edx = pointer to sockaddr struct ; esi = length of sockaddr struct ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label socket_connect
 --------------------------------------------------------------—; ; socket_connect: Connect to the remote host. ; ; IN: ecx = socket number ; edx = pointer to sockaddr struct ; esi = length of sockaddr struct ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label connect_notsupp
 
label socket_listen
 --------------------------------------------------------------—; ; socket_listen: Listen for incoming connections. ; ; IN: ecx = socket number ; edx = backlog in edx ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label socket_accept
 --------------------------------------------------------------—; ; socket_accept: Accept an incoming connection. ; ; IN: ecx = socket number (of listening socket) ; edx = ptr to sockaddr struct ; esi = length of sockaddr struct ; ; OUT: eax = newly created socket num ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label socket_close
 --------------------------------------------------------------—; ; socket_close: Close the socket (and connection). ; ; IN: ecx = socket number ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label socket_receive
 --------------------------------------------------------------—; ; socket_receive: Receive some data from the remote end. ; ; IN: ecx = socket number ; edx = addr to application buffer ; esi = length of application buffer ; edi = flags ; ; OUT: eax = number of bytes copied ; eax = -1 on error ; eax = 0 when socket has been closed by the remote end ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label socket_receive_dgram
 
label socket_receive_tcp
 
label socket_receive_local
 
label socket_receive_stream
 
label socket_send
 --------------------------------------------------------------—; ; socket_send: Send some data to the remote end. ; ; IN: ecx = socket number ; edx = pointer to data ; esi = data length ; edi = flags ; ; OUT: eax = number of bytes sent ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label socket_send_udp
 
label socket_send_tcp
 
label socket_send_ip
 
label socket_send_icmp
 
label socket_send_local
 
label socket_send_local_initialized
 
label socket_get_opt
 --------------------------------------------------------------—; ; socket_get_opt: Read a socket option ; ; IN: ecx = socket number ; edx = pointer to socket options struct ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label socket_set_opt
 --------------------------------------------------------------—; ; socket_set_options: Set a socket option. ; ; IN: ecx = socket number ; edx = pointer to socket options struct ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label socket_pair
 --------------------------------------------------------------—; ; socket_pair: Allocate a pair of linked local sockets. ; ; IN: / ; ; OUT: eax = socket1 num on success ; eax = -1 on error ; ebx = socket2 num on success ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label socket_debug
 --------------------------------------------------------------—; ; socket_debug: Copy socket variables to application buffer. ; ; IN: ecx = socket number ; edx = pointer to application buffer ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—; More...
 
label socket_find_port
 --------------------------------------------------------------—; ; socket_find_port: ; Fill in the local port number for TCP and UDP sockets ; This procedure always works because the number of sockets is ; limited to a smaller number then the number of possible ports ; ; IN: eax = socket pointer ; ; OUT: / ; ; --------------------------------------------------------------—; More...
 
label socket_check_port
 --------------------------------------------------------------—; ; socket_check_port: (to be used with AF_INET only!) ; Checks if a local port number is unused ; If the proposed port number is unused, it is filled in in the ; socket structure. ; ; IN: eax = socket ptr ; bx = proposed socket number (network byte order) ; ; OUT: ZF = set on error ; ; --------------------------------------------------------------—; More...
 
label socket_input
 --------------------------------------------------------------—; ; socket_input: Update a (stateless) socket with received data. ; ; Note: The socket's mutex should already be set ! ; ; IN: eax = socket ptr ; ecx = data size ; esi = ptr to data ; [esp] = ptr to buf ; ; OUT: / ; ; --------------------------------------------------------------—; More...
 
label socket_ring_create
 --------------------------------------------------------------—; ; socket_ring_create: Create a ringbuffer for sockets. ; ; IN: eax = ptr to ring struct ; ; OUT: eax = 0 on error ; eax = start ptr ; ; --------------------------------------------------------------—; More...
 
label socket_ring_write
 --------------------------------------------------------------—; ; socket_ring_write: Write data to ring buffer. ; ; IN: eax = ptr to ring struct ; ecx = data size ; esi = ptr to data ; ; OUT: ecx = number of bytes stored ; ; --------------------------------------------------------------—; More...
 
label socket_ring_read
 --------------------------------------------------------------—; ; socket_ring_read: Read from ring buffer ; ; IN: eax = ring struct ptr ; ecx = bytes to read ; edx = offset ; edi = ptr to buffer start ; ; OUT: eax = unchanged ; ecx = number of bytes read (0 on error) ; edx = destroyed ; esi = destroyed ; edi = ptr to buffer end ; ; --------------------------------------------------------------—; More...
 
label socket_ring_free
 --------------------------------------------------------------—; ; socket_ring_free: Free data from a ringbuffer. ; ; IN: eax = ptr to ring struct ; ecx = data size ; ; OUT: ecx = number of freed bytes ; ; --------------------------------------------------------------—; More...
 
label socket_block
 --------------------------------------------------------------—; ; socket_block: Suspend the thread attached to a socket. ; ; IN: eax = socket ptr ; ; OUT: eax = unchanged ; ; --------------------------------------------------------------—; More...
 
label socket_notify
 --------------------------------------------------------------—; ; socket_notify: Wake up socket owner thread. ; ; IN: eax = socket ptr ; ; OUT: eax = unchanged ; ; --------------------------------------------------------------—; More...
 
label socket_alloc
 --------------------------------------------------------------—; ; socket_alloc: Allocate memory for socket and put new socket ; into the list. Newly created socket is initialized with calling ; PID and given a socket number. ; ; IN: / ; ; OUT: eax = socket ptr on success ; eax = 0 on error ; edi = socket number on success ; ; --------------------------------------------------------------—; More...
 
label socket_free
 --------------------------------------------------------------—; ; socket_free: Free socket data memory and remove socket from ; the list. Caller should lock and unlock socket_mutex. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—; More...
 
label socket_fork
 --------------------------------------------------------------—; ; socket_fork: Create a child socket. ; ; IN: ebx = socket number ; ; OUT: eax = child socket number on success ; eax = 0 on error ; ; --------------------------------------------------------------—; More...
 
label socket_num_to_ptr
 --------------------------------------------------------------—; ; socket_num_to_ptr: Get socket structure address by its number. ; ; IN: ecx = socket number ; ; OUT: eax = socket ptr ; eax = 0 on error ; ; --------------------------------------------------------------—; More...
 
label socket_ptr_to_num
 --------------------------------------------------------------—; ; socket_ptr_to_num: Get socket number by its address. ; ; IN: eax = socket ptr ; ; OUT: eax = socket number ; eax = 0 on error ; ZF = set on error ; ; --------------------------------------------------------------—; More...
 
label socket_check
 --------------------------------------------------------------—; ; socket_check: Checks if the given ptr is really a socket ptr. ; ; IN: eax = socket ptr ; ; OUT: eax = 0 on error ; ZF = set on error ; ; --------------------------------------------------------------—; More...
 
label socket_check_owner
 --------------------------------------------------------------—; ; socket_check_owner: Check if the caller app owns the socket. ; ; IN: eax = socket ptr ; ; OUT: ZF = true/false ; ; --------------------------------------------------------------—; More...
 
label socket_process_end
 --------------------------------------------------------------—; ; socket_process_end: Kernel calls this function when a certain ; process ends. This function will check if the process had any ; open sockets and update them accordingly (clean up). ; ; IN: edx = pid ; ; OUT: / ; ; --------------------------------------------------------------—; More...
 
label socket_is_connecting
 --------------------------------------------------------------—; ; socket_is_connecting: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—; More...
 
label socket_is_connected
 --------------------------------------------------------------—; ; socket_is_connected: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—; More...
 
label socket_is_disconnecting
 --------------------------------------------------------------—; ; socket_is_disconnecting: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—; More...
 
label socket_is_disconnected
 --------------------------------------------------------------—; ; socket_is_disconnected: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—; More...
 
label socket_cant_recv_more
 --------------------------------------------------------------—; ; socket_cant_recv_more: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—; More...
 
label socket_cant_send_more
 --------------------------------------------------------------—; ; socket_cant_send_more: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—; More...
 

Macro Definition Documentation

◆ socket_init

#define socket_init

--------------------------------------------------------------—; ; socket_init ; ; --------------------------------------------------------------—;

Source
network/socket.inc:221

Variable Documentation

◆ connect_notsupp

label connect_notsupp

◆ last_socket_num

dd last_socket_num
Initial value
?
Source
network/socket.inc:208

◆ last_TCP_port

dw last_TCP_port
Initial value
?
Source
network/socket.inc:210

◆ last_UDP_port

dw last_UDP_port

last used ephemeral port

Initial value
?
Source
network/socket.inc:209

◆ net_sockets

rd net_sockets
Initial value
4
Source
network/socket.inc:207

◆ socket_accept

label socket_accept

--------------------------------------------------------------—; ; socket_accept: Accept an incoming connection. ; ; IN: ecx = socket number (of listening socket) ; edx = ptr to sockaddr struct ; esi = length of sockaddr struct ; ; OUT: eax = newly created socket num ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:663

◆ socket_alloc

label socket_alloc

--------------------------------------------------------------—; ; socket_alloc: Allocate memory for socket and put new socket ; into the list. Newly created socket is initialized with calling ; PID and given a socket number. ; ; IN: / ; ; OUT: eax = socket ptr on success ; eax = 0 on error ; edi = socket number on success ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1973

◆ socket_bind

label socket_bind

--------------------------------------------------------------—; ; socket_bind: Bind to a local port. ; ; IN: ecx = socket number ; edx = pointer to sockaddr struct ; esi = length of sockaddr struct ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:441

◆ socket_block

label socket_block

--------------------------------------------------------------—; ; socket_block: Suspend the thread attached to a socket. ; ; IN: eax = socket ptr ; ; OUT: eax = unchanged ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1859

◆ socket_cant_recv_more

label socket_cant_recv_more

--------------------------------------------------------------—; ; socket_cant_recv_more: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2514

◆ socket_cant_send_more

label socket_cant_send_more

--------------------------------------------------------------—; ; socket_cant_send_more: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2533

◆ socket_check

label socket_check

--------------------------------------------------------------—; ; socket_check: Checks if the given ptr is really a socket ptr. ; ; IN: eax = socket ptr ; ; OUT: eax = 0 on error ; ZF = set on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2292

◆ socket_check_owner

label socket_check_owner

--------------------------------------------------------------—; ; socket_check_owner: Check if the caller app owns the socket. ; ; IN: eax = socket ptr ; ; OUT: ZF = true/false ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2331

◆ socket_check_port

label socket_check_port

--------------------------------------------------------------—; ; socket_check_port: (to be used with AF_INET only!) ; Checks if a local port number is unused ; If the proposed port number is unused, it is filled in in the ; socket structure. ; ; IN: eax = socket ptr ; bx = proposed socket number (network byte order) ; ; OUT: ZF = set on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1515

◆ socket_close

label socket_close

--------------------------------------------------------------—; ; socket_close: Close the socket (and connection). ; ; IN: ecx = socket number ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:734

◆ socket_connect

label socket_connect

--------------------------------------------------------------—; ; socket_connect: Connect to the remote host. ; ; IN: ecx = socket number ; edx = pointer to sockaddr struct ; esi = length of sockaddr struct ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:533

◆ socket_debug

label socket_debug

--------------------------------------------------------------—; ; socket_debug: Copy socket variables to application buffer. ; ; IN: ecx = socket number ; edx = pointer to application buffer ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1388

◆ socket_find_port

label socket_find_port

--------------------------------------------------------------—; ; socket_find_port: ; Fill in the local port number for TCP and UDP sockets ; This procedure always works because the number of sockets is ; limited to a smaller number then the number of possible ports ; ; IN: eax = socket pointer ; ; OUT: / ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1454

◆ socket_fork

label socket_fork

--------------------------------------------------------------—; ; socket_fork: Create a child socket. ; ; IN: ebx = socket number ; ; OUT: eax = child socket number on success ; eax = 0 on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2158

◆ socket_free

label socket_free

--------------------------------------------------------------—; ; socket_free: Free socket data memory and remove socket from ; the list. Caller should lock and unlock socket_mutex. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2087

◆ socket_get_opt

label socket_get_opt

--------------------------------------------------------------—; ; socket_get_opt: Read a socket option ; ; IN: ecx = socket number ; edx = pointer to socket options struct ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1176

◆ socket_input

label socket_input

--------------------------------------------------------------—; ; socket_input: Update a (stateless) socket with received data. ; ; Note: The socket's mutex should already be set ! ; ; IN: eax = socket ptr ; ecx = data size ; esi = ptr to data ; [esp] = ptr to buf ; ; OUT: / ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1578

◆ socket_is_connected

label socket_is_connected

--------------------------------------------------------------—; ; socket_is_connected: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2453

◆ socket_is_connecting

label socket_is_connecting

--------------------------------------------------------------—; ; socket_is_connecting: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2433

◆ socket_is_disconnected

label socket_is_disconnected

--------------------------------------------------------------—; ; socket_is_disconnected: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2494

◆ socket_is_disconnecting

label socket_is_disconnecting

--------------------------------------------------------------—; ; socket_is_disconnecting: Update socket state. ; ; IN: eax = socket ptr ; ; OUT: / ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2474

◆ socket_listen

label socket_listen

--------------------------------------------------------------—; ; socket_listen: Listen for incoming connections. ; ; IN: ecx = socket number ; edx = backlog in edx ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:593

◆ socket_mutex

MUTEX socket_mutex
Initial value
Source
network/socket.inc:211

◆ socket_notify

label socket_notify

--------------------------------------------------------------—; ; socket_notify: Wake up socket owner thread. ; ; IN: eax = socket ptr ; ; OUT: eax = unchanged ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1900

◆ socket_num_to_ptr

label socket_num_to_ptr

--------------------------------------------------------------—; ; socket_num_to_ptr: Get socket structure address by its number. ; ; IN: ecx = socket number ; ; OUT: eax = socket ptr ; eax = 0 on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2216

◆ socket_open

label socket_open

--------------------------------------------------------------—; ; socket_open: Create a new socket. ; ; IN: ecx = domain ; edx = type ; esi = protocol ; ; OUT: eax = socket number ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:302

◆ socket_pair

label socket_pair

--------------------------------------------------------------—; ; socket_pair: Allocate a pair of linked local sockets. ; ; IN: / ; ; OUT: eax = socket1 num on success ; eax = -1 on error ; ebx = socket2 num on success ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1316

◆ socket_process_end

label socket_process_end

--------------------------------------------------------------—; ; socket_process_end: Kernel calls this function when a certain ; process ends. This function will check if the process had any ; open sockets and update them accordingly (clean up). ; ; IN: edx = pid ; ; OUT: / ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2358

◆ socket_ptr_to_num

label socket_ptr_to_num

--------------------------------------------------------------—; ; socket_ptr_to_num: Get socket number by its address. ; ; IN: eax = socket ptr ; ; OUT: eax = socket number ; eax = 0 on error ; ZF = set on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:2264

◆ socket_receive

label socket_receive

--------------------------------------------------------------—; ; socket_receive: Receive some data from the remote end. ; ; IN: ecx = socket number ; edx = addr to application buffer ; esi = length of application buffer ; edi = flags ; ; OUT: eax = number of bytes copied ; eax = -1 on error ; eax = 0 when socket has been closed by the remote end ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:796

◆ socket_receive_dgram

label socket_receive_dgram

◆ socket_receive_local

label socket_receive_local

◆ socket_receive_stream

label socket_receive_stream

◆ socket_receive_tcp

label socket_receive_tcp

◆ socket_ring_create

label socket_ring_create

--------------------------------------------------------------—; ; socket_ring_create: Create a ringbuffer for sockets. ; ; IN: eax = ptr to ring struct ; ; OUT: eax = 0 on error ; eax = start ptr ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1622

◆ socket_ring_free

label socket_ring_free

--------------------------------------------------------------—; ; socket_ring_free: Free data from a ringbuffer. ; ; IN: eax = ptr to ring struct ; ecx = data size ; ; OUT: ecx = number of freed bytes ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1810

◆ socket_ring_read

label socket_ring_read

--------------------------------------------------------------—; ; socket_ring_read: Read from ring buffer ; ; IN: eax = ring struct ptr ; ecx = bytes to read ; edx = offset ; edi = ptr to buffer start ; ; OUT: eax = unchanged ; ecx = number of bytes read (0 on error) ; edx = destroyed ; esi = destroyed ; edi = ptr to buffer end ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1742

◆ socket_ring_write

label socket_ring_write

--------------------------------------------------------------—; ; socket_ring_write: Write data to ring buffer. ; ; IN: eax = ptr to ring struct ; ecx = data size ; esi = ptr to data ; ; OUT: ecx = number of bytes stored ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1668

◆ socket_send

label socket_send

--------------------------------------------------------------—; ; socket_send: Send some data to the remote end. ; ; IN: ecx = socket number ; edx = pointer to data ; esi = data length ; edi = flags ; ; OUT: eax = number of bytes sent ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1005

◆ socket_send_icmp

label socket_send_icmp

◆ socket_send_ip

label socket_send_ip

◆ socket_send_local

label socket_send_local

◆ socket_send_local_initialized

label socket_send_local_initialized

◆ socket_send_tcp

label socket_send_tcp

◆ socket_send_udp

label socket_send_udp

◆ socket_set_opt

label socket_set_opt

--------------------------------------------------------------—; ; socket_set_options: Set a socket option. ; ; IN: ecx = socket number ; edx = pointer to socket options struct ; ; OUT: eax = 0 on success ; eax = -1 on error ; ebx = errorcode on error ; ; --------------------------------------------------------------—;

Source
network/socket.inc:1238

◆ sys_socket

label sys_socket

--------------------------------------------------------------—; ; Sockets API (system function 75) ; ; --------------------------------------------------------------—;

Source
network/socket.inc:257