Veritable Lasagna
An Allocator & Data Structure Library for C.
Loading...
Searching...
No Matches
vl_socket_win32.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winsock2.h>
#include <ws2tcpip.h>
+ Include dependency graph for vl_socket_win32.c:

Data Structures

struct  vl_socket
 Opaque socket handle. More...
 

Functions

vl_socket_result vlSocketStartup (void)
 Initializes the process-wide socket subsystem.
 
void vlSocketShutdownLibrary (void)
 Shuts down the process-wide socket subsystem.
 
vl_socket vlSocketNew (vl_socket_domain domain, vl_socket_type type)
 Creates a new socket.
 
void vlSocketDelete (vl_socket socket)
 Closes and deletes a socket handle.
 
vl_socket_result vlSocketBind (vl_socket socket, const vl_socket_address *address)
 Binds a socket to a local address.
 
vl_socket_result vlSocketListen (vl_socket socket, vl_int_t backlog)
 Marks a stream socket as a passive listening socket.
 
vl_socket vlSocketAccept (vl_socket socket, vl_socket_address *outAddress)
 Accepts an incoming connection from a listening socket.
 
vl_socket_result vlSocketConnect (vl_socket socket, const vl_socket_address *address)
 Connects a socket to a remote address.
 
vl_int64_t vlSocketSend (vl_socket socket, const void *buffer, vl_memsize_t length)
 Sends bytes through a connected socket.
 
vl_int64_t vlSocketReceive (vl_socket socket, void *buffer, vl_memsize_t length)
 Receives bytes from a connected socket.
 
vl_socket_result vlSocketShutdown (vl_socket socket, vl_socket_shutdown how)
 Shuts down part or all of a full-duplex connection.
 
vl_socket_result vlSocketSetBlocking (vl_socket socket, vl_bool_t blocking)
 Configures whether a socket operates in blocking mode.
 
vl_bool_t vlSocketAddressSetIPv4 (vl_socket_address *address, vl_uint8_t a, vl_uint8_t b, vl_uint8_t c, vl_uint8_t d, vl_uint16_t port)
 Fills a socket address with an IPv4 address and port.
 
vl_bool_t vlSocketAddressSetIPv6 (vl_socket_address *address, const vl_uint8_t ipv6Bytes[16], vl_uint16_t port)
 Fills a socket address with an IPv6 address and port.
 
vl_socket_result vlSocketSetReuseAddress (vl_socket socket, vl_bool_t enabled)
 Configures whether local address reuse is enabled for a socket.
 
vl_socket_result vlSocketSetNoDelay (vl_socket socket, vl_bool_t enabled)
 Configures whether the Nagle algorithm is disabled for a TCP socket.
 
vl_socket_result vlSocketSetKeepAlive (vl_socket socket, vl_bool_t enabled)
 Configures whether TCP keep-alive probes are enabled.
 
vl_socket_result vlSocketGetReuseAddress (vl_socket socket, vl_bool_t *outEnabled)
 Checks if local address reuse is enabled for a socket.
 
vl_socket_result vlSocketGetNoDelay (vl_socket socket, vl_bool_t *outEnabled)
 Checks if the Nagle algorithm is disabled for a TCP socket.
 
vl_socket_result vlSocketGetKeepAlive (vl_socket socket, vl_bool_t *outEnabled)
 Checks if TCP keep-alive probes are enabled.
 
vl_socket_result vlSocketIsBlocking (vl_socket socket, vl_bool_t *outBlocking)
 Checks if a socket is in blocking mode.
 
const char * vlSocketError (void)
 Returns a human-readable description of the most recent socket error.
 
vl_socket_result vlSocketGetRemoteAddress (vl_socket socket, vl_socket_address *outAddress)
 Retrieves the remote address that the socket is connected to.
 
vl_bool_t vlSocketAddressToString (const vl_socket_address *address, char *buffer, vl_memsize_t bufferSize)
 Converts a socket address to a human-readable string.
 
vl_bool_t vlSocketAddressFromString (vl_socket_address *address, const char *string)
 Parses a human-readable string into a socket address.
 
vl_socket_result vlSocketGetLocalAddress (vl_socket socket, vl_socket_address *outAddress)
 Retrieves the local address that the socket is bound to.
 

Data Structure Documentation

◆ vl_socket_

struct vl_socket_

Opaque socket handle.

The underlying representation is platform-specific:

  • POSIX backends typically wrap a file descriptor
  • Win32 backends typically wrap a Winsock SOCKET
+ Collaboration diagram for vl_socket:
Data Fields
vl_bool_t blocking
vl_socket_domain domain
int fd
SOCKET fd
vl_socket_type type

Function Documentation

◆ vlSocketAccept()

vl_socket vlSocketAccept ( vl_socket  socket,
vl_socket_address outAddress 
)

Accepts an incoming connection from a listening socket.

On success, returns a newly allocated socket handle representing the accepted connection.

If outAddress is non-NULL, it receives the remote peer address.

Contract

  • Ownership: The caller owns the returned socket handle and must release it with vlSocketDelete.
  • Lifetime: socket must remain valid throughout the call. outAddress, if provided, must be writable.
  • Thread Safety: Safe to call, though concurrent accepts on the same listening socket are subject to backend semantics.
  • Nullability: Returns VL_SOCKET_NULL if socket is NULL or if the accept operation fails.
  • Error Conditions: Returns VL_SOCKET_NULL on backend failure or if the operation would block in non-blocking mode.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: Allocates heap metadata for the accepted socket.
  • Return-value Semantics: Returns a new socket handle on success, or VL_SOCKET_NULL on failure.
Parameters
socketlistening socket
outAddressoptional pointer receiving the remote address
Returns
accepted socket handle, or VL_SOCKET_NULL on failure

◆ vlSocketAddressFromString()

vl_bool_t vlSocketAddressFromString ( vl_socket_address address,
const char *  string 
)

Parses a human-readable string into a socket address.

Supports IPv4 ("a.b.c.d:port") and IPv6 ("[addr]:port") formats.

Contract

  • Ownership: Unchanged.
  • Lifetime: address and string must remain valid for the duration of the call.
  • Thread Safety: Thread-safe.
  • Nullability: Returns VL_FALSE if address or string is NULL.
  • Error Conditions: Returns VL_FALSE if the string format is invalid.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_TRUE on success, VL_FALSE on failure.
Parameters
addressdestination address structure
stringsource string to parse
Returns
boolean indicating success

◆ vlSocketAddressSetIPv4()

vl_bool_t vlSocketAddressSetIPv4 ( vl_socket_address address,
vl_uint8_t  a,
vl_uint8_t  b,
vl_uint8_t  c,
vl_uint8_t  d,
vl_uint16_t  port 
)

Fills a socket address with an IPv4 address and port.

The port argument is specified in host byte order.

Contract

  • Ownership: Unchanged.
  • Lifetime: address must remain valid for the duration of the call.
  • Thread Safety: Thread-safe.
  • Nullability: Returns VL_FALSE if address is NULL.
  • Error Conditions: None.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_TRUE on success, VL_FALSE on invalid input.
Parameters
addressdestination address structure
afirst IPv4 octet
bsecond IPv4 octet
cthird IPv4 octet
dfourth IPv4 octet
portport in host byte order
Returns
boolean indicating success

◆ vlSocketAddressSetIPv6()

vl_bool_t vlSocketAddressSetIPv6 ( vl_socket_address address,
const vl_uint8_t  ipv6Bytes[16],
vl_uint16_t  port 
)

Fills a socket address with an IPv6 address and port.

The sixteen-byte address is copied from ipv6Bytes. The port argument is specified in host byte order.

Contract

  • Ownership: Unchanged.
  • Lifetime: address and ipv6Bytes must remain valid for the duration of the call.
  • Thread Safety: Thread-safe.
  • Nullability: Returns VL_FALSE if address or ipv6Bytes is NULL.
  • Error Conditions: None.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_TRUE on success, VL_FALSE on invalid input.
Parameters
addressdestination address structure
ipv6Bytespointer to 16 bytes of IPv6 address data
portport in host byte order
Returns
boolean indicating success

◆ vlSocketAddressToString()

vl_bool_t vlSocketAddressToString ( const vl_socket_address address,
char *  buffer,
vl_memsize_t  bufferSize 
)

Converts a socket address to a human-readable string.

The output format is typically "a.b.c.d:port" for IPv4 and "[addr]:port" for IPv6.

Contract

  • Ownership: Unchanged.
  • Lifetime: address and buffer must remain valid for the duration of the call.
  • Thread Safety: Thread-safe.
  • Nullability: Returns VL_FALSE if address or buffer is NULL.
  • Error Conditions: Returns VL_FALSE if bufferSize is too small.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_TRUE on success, VL_FALSE on failure.
Parameters
addresssource address structure
bufferdestination string buffer
bufferSizesize of the destination buffer
Returns
boolean indicating success

◆ vlSocketBind()

vl_socket_result vlSocketBind ( vl_socket  socket,
const vl_socket_address address 
)

Binds a socket to a local address.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket and address must remain valid for the duration of the call.
  • Thread Safety: Safe to call, but callers must externally synchronize semantic use of the same socket if required.
  • Nullability: Returns VL_SOCKET_ERROR_INVALID_ARGUMENT if socket or address is NULL.
  • Error Conditions: Returns VL_SOCKET_ERROR_BIND on backend bind failure.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_SOCKET_SUCCESS on success, otherwise an error code.
Parameters
socketsocket handle
addresslocal address to bind
Returns
operation result code

◆ vlSocketConnect()

vl_socket_result vlSocketConnect ( vl_socket  socket,
const vl_socket_address address 
)

Connects a socket to a remote address.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket and address must remain valid for the duration of the call.
  • Thread Safety: Safe to call with normal external synchronization expectations for the same socket.
  • Nullability: Returns VL_SOCKET_ERROR_INVALID_ARGUMENT if socket or address is NULL.
  • Error Conditions: Returns VL_SOCKET_ERROR_CONNECT on backend connection failure.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_SOCKET_SUCCESS on success, otherwise an error code.
Parameters
socketsocket handle
addressremote address
Returns
operation result code

◆ vlSocketDelete()

void vlSocketDelete ( vl_socket  socket)

Closes and deletes a socket handle.

Contract

  • Ownership: Releases ownership of the socket and associated platform handle.
  • Lifetime: The handle becomes invalid immediately after this call.
  • Thread Safety: Safe to call provided no other thread is concurrently using or deleting the same socket.
  • Nullability: Safe to call with VL_SOCKET_NULL (no-op).
  • Error Conditions: None reported through the API.
  • Undefined Behavior: Double deletion or concurrent use-after-delete.
  • Memory Allocation Expectations: Releases heap metadata and the native socket handle.
  • Return-value Semantics: None (void).
Parameters
socketsocket handle to destroy

◆ vlSocketError()

const char * vlSocketError ( void  )

Returns a human-readable description of the most recent socket error.

The returned string is owned by the library and must not be modified or freed by the caller. The storage may be thread-local, static, or overwritten by subsequent socket API calls.

Contract

  • Ownership: The caller does not own the returned string.
  • Lifetime: The pointer remains valid until overwritten by a later backend error query or until program termination, depending on implementation.
  • Thread Safety: Backend-dependent; callers should treat the returned pointer as ephemeral.
  • Nullability: May return NULL if no additional error text is available.
  • Error Conditions: None.
  • Undefined Behavior: Modifying or freeing the returned string.
  • Memory Allocation Expectations: None required by the caller.
  • Return-value Semantics: Returns a pointer to a diagnostic string, or NULL.
Returns
error message string or NULL

◆ vlSocketGetKeepAlive()

vl_socket_result vlSocketGetKeepAlive ( vl_socket  socket,
vl_bool_t outEnabled 
)

Checks if TCP keep-alive probes are enabled.

Parameters
socketsocket handle
outEnabledpointer receiving the enabled status
Returns
operation result code

◆ vlSocketGetLocalAddress()

vl_socket_result vlSocketGetLocalAddress ( vl_socket  socket,
vl_socket_address outAddress 
)

Retrieves the local address that the socket is bound to.

This function retrieves the local address information for the given socket. This is particularly useful after binding to an ephemeral port (port 0) to determine which port was actually assigned by the operating system.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket and outAddress must remain valid for the duration of the call.
  • Thread Safety: Safe to call with normal external synchronization expectations for the same socket.
  • Nullability: Returns VL_SOCKET_ERROR_INVALID_ARGUMENT if socket or outAddress is NULL.
  • Error Conditions: Returns VL_SOCKET_ERROR_BIND or a similar code if the backend getsockname call fails.
  • Undefined Behavior: Calling this on a socket that is not yet bound may return platform-defined results.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_SOCKET_SUCCESS on success, otherwise an error code.
Parameters
socketsocket handle
outAddresspointer to address structure where the local address will be stored
Returns
operation result code

◆ vlSocketGetNoDelay()

vl_socket_result vlSocketGetNoDelay ( vl_socket  socket,
vl_bool_t outEnabled 
)

Checks if the Nagle algorithm is disabled for a TCP socket.

Parameters
socketsocket handle
outEnabledpointer receiving the enabled status
Returns
operation result code

◆ vlSocketGetRemoteAddress()

vl_socket_result vlSocketGetRemoteAddress ( vl_socket  socket,
vl_socket_address outAddress 
)

Retrieves the remote address that the socket is connected to.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket and outAddress must remain valid for the duration of the call.
  • Thread Safety: Safe to call with normal external synchronization expectations for the same socket.
  • Nullability: Returns VL_SOCKET_ERROR_INVALID_ARGUMENT if socket or outAddress is NULL.
  • Error Conditions: Returns VL_SOCKET_ERROR_NOT_CONNECTED if the socket is not connected or a backend error occurs.
  • Undefined Behavior: Calling this on a socket that is not connected may return platform-defined results.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_SOCKET_SUCCESS on success, otherwise an error code.
Parameters
socketsocket handle
outAddresspointer to address structure where the remote address will be stored
Returns
operation result code

◆ vlSocketGetReuseAddress()

vl_socket_result vlSocketGetReuseAddress ( vl_socket  socket,
vl_bool_t outEnabled 
)

Checks if local address reuse is enabled for a socket.

Parameters
socketsocket handle
outEnabledpointer receiving the enabled status
Returns
operation result code

◆ vlSocketIsBlocking()

vl_socket_result vlSocketIsBlocking ( vl_socket  socket,
vl_bool_t outBlocking 
)

Checks if a socket is in blocking mode.

Parameters
socketsocket handle
outBlockingpointer receiving the blocking status
Returns
operation result code

◆ vlSocketListen()

vl_socket_result vlSocketListen ( vl_socket  socket,
vl_int_t  backlog 
)

Marks a stream socket as a passive listening socket.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket must remain valid for the duration of the call.
  • Thread Safety: Safe to call with normal external synchronization expectations for the same socket.
  • Nullability: Returns VL_SOCKET_ERROR_INVALID_ARGUMENT if socket is NULL.
  • Error Conditions: Returns VL_SOCKET_ERROR_LISTEN if the backend listen call fails.
  • Undefined Behavior: Calling on an incompatible socket type may fail.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_SOCKET_SUCCESS on success, otherwise an error code.
Parameters
socketsocket handle
backlogmaximum pending connection backlog
Returns
operation result code

◆ vlSocketNew()

vl_socket vlSocketNew ( vl_socket_domain  domain,
vl_socket_type  type 
)

Creates a new socket.

Contract

  • Ownership: The caller owns the returned vl_socket handle and must release it with vlSocketDelete.
  • Lifetime: The returned handle remains valid until deleted.
  • Thread Safety: This function is thread-safe assuming the socket subsystem has been properly initialized.
  • Nullability: Returns VL_SOCKET_NULL on failure.
  • Error Conditions: Returns VL_SOCKET_NULL if the subsystem is not initialized, allocation fails, or the underlying socket creation call fails.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: Allocates heap metadata for the socket handle.
  • Return-value Semantics: Returns a valid opaque socket handle on success, or VL_SOCKET_NULL on error.
Parameters
domainsocket address family
typesocket kind
Returns
socket handle, or VL_SOCKET_NULL on failure

◆ vlSocketReceive()

vl_int64_t vlSocketReceive ( vl_socket  socket,
void *  buffer,
vl_memsize_t  length 
)

Receives bytes from a connected socket.

A return value of 0 typically indicates an orderly remote shutdown for stream sockets.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket and buffer must remain valid for the duration of the call.
  • Thread Safety: Safe to call, though callers should externally synchronize concurrent reads when protocol framing matters.
  • Nullability: Returns -1 if socket or buffer is NULL.
  • Error Conditions: Returns -1 if the backend receive operation fails.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns the number of bytes received on success, 0 on end-of-stream, or -1 on error.
Parameters
socketsocket handle
bufferdestination buffer
lengthmaximum number of bytes to receive
Returns
bytes actually received, 0 on orderly close, or -1 on error

◆ vlSocketSend()

vl_int64_t vlSocketSend ( vl_socket  socket,
const void *  buffer,
vl_memsize_t  length 
)

Sends bytes through a connected socket.

This function may perform a partial send. A successful return value smaller than length does not indicate an error.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket and buffer must remain valid for the duration of the call.
  • Thread Safety: Safe to call, though callers should externally synchronize concurrent writes when message framing matters.
  • Nullability: Returns -1 if socket or buffer is NULL.
  • Error Conditions: Returns -1 if the backend send operation fails.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns the number of bytes sent on success, or -1 on error.
Parameters
socketsocket handle
buffersource buffer
lengthnumber of bytes requested to send
Returns
bytes actually sent, or -1 on error

◆ vlSocketSetBlocking()

vl_socket_result vlSocketSetBlocking ( vl_socket  socket,
vl_bool_t  blocking 
)

Configures whether a socket operates in blocking mode.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket must remain valid for the duration of the call.
  • Thread Safety: Safe to call with normal external synchronization expectations for the same socket.
  • Nullability: Returns VL_SOCKET_ERROR_INVALID_ARGUMENT if socket is NULL.
  • Error Conditions: Returns VL_SOCKET_ERROR_SET_OPTION if the backend mode change fails.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_SOCKET_SUCCESS on success, otherwise an error code.
Parameters
socketsocket handle
blockingVL_TRUE for blocking mode, VL_FALSE for non-blocking mode
Returns
operation result code

◆ vlSocketSetKeepAlive()

vl_socket_result vlSocketSetKeepAlive ( vl_socket  socket,
vl_bool_t  enabled 
)

Configures whether TCP keep-alive probes are enabled.

When enabled, the underlying TCP implementation will periodically send keep-alive probes on an idle connection to verify the remote endpoint is still reachable.

This function typically corresponds to the SO_KEEPALIVE socket option.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket must remain valid for the duration of the call.
  • Thread Safety: Safe to call with normal external synchronization expectations for the same socket.
  • Nullability: Returns VL_SOCKET_ERROR_INVALID_ARGUMENT if socket is NULL.
  • Error Conditions: Returns VL_SOCKET_ERROR_SET_OPTION if the backend socket option call fails.
  • Undefined Behavior: Calling this on a non-TCP socket is platform-dependent.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_SOCKET_SUCCESS on success, otherwise an error code.
Parameters
socketsocket handle
enabledVL_TRUE to enable keep-alive, VL_FALSE to disable it
Returns
operation result code

◆ vlSocketSetNoDelay()

vl_socket_result vlSocketSetNoDelay ( vl_socket  socket,
vl_bool_t  enabled 
)

Configures whether the Nagle algorithm is disabled for a TCP socket.

When enabled (no-delay is VL_TRUE), small packets are sent as soon as possible without waiting for additional data to fill a segment. This reduces latency at the potential cost of network efficiency.

This function typically corresponds to the TCP_NODELAY socket option.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket must remain valid for the duration of the call.
  • Thread Safety: Safe to call with normal external synchronization expectations for the same socket.
  • Nullability: Returns VL_SOCKET_ERROR_INVALID_ARGUMENT if socket is NULL.
  • Error Conditions: Returns VL_SOCKET_ERROR_SET_OPTION if the backend socket option call fails.
  • Undefined Behavior: Calling this on a non-TCP socket is platform-dependent.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_SOCKET_SUCCESS on success, otherwise an error code.
Parameters
socketsocket handle
enabledVL_TRUE to disable Nagle's algorithm, VL_FALSE to enable it
Returns
operation result code

◆ vlSocketSetReuseAddress()

vl_socket_result vlSocketSetReuseAddress ( vl_socket  socket,
vl_bool_t  enabled 
)

Configures whether local address reuse is enabled for a socket.

This function requests that the underlying socket enable or disable the platform's address reuse option, typically corresponding to SO_REUSEADDR. This is commonly used for server sockets that need to re-bind to a recently used local address without waiting for normal timeout expiration.

The exact backend behavior may vary slightly by platform. In particular, address reuse semantics are not perfectly identical between POSIX systems and Winsock.

For best portability, this option should generally be configured before calling vlSocketBind.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket must remain valid for the duration of the call.
  • Thread Safety: Safe to call with normal external synchronization expectations for the same socket.
  • Nullability: Returns VL_SOCKET_ERROR_INVALID_ARGUMENT if socket is NULL.
  • Error Conditions: Returns VL_SOCKET_ERROR_SET_OPTION if the backend socket option call fails.
  • Undefined Behavior: Backend behavior may be implementation-defined if this is called after binding, depending on platform semantics.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_SOCKET_SUCCESS on success, otherwise an error code.
Parameters
socketsocket handle
enabledVL_TRUE to enable local address reuse, VL_FALSE to disable it
Returns
operation result code

◆ vlSocketShutdown()

vl_socket_result vlSocketShutdown ( vl_socket  socket,
vl_socket_shutdown  how 
)

Shuts down part or all of a full-duplex connection.

Contract

  • Ownership: Unchanged.
  • Lifetime: socket must remain valid for the duration of the call.
  • Thread Safety: Safe to call with normal external synchronization expectations for the same socket.
  • Nullability: Returns VL_SOCKET_ERROR_INVALID_ARGUMENT if socket is NULL.
  • Error Conditions: Returns VL_SOCKET_ERROR_SHUTDOWN if the backend shutdown call fails.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: None.
  • Return-value Semantics: Returns VL_SOCKET_SUCCESS on success, otherwise an error code.
Parameters
socketsocket handle
howwhich direction(s) to shut down
Returns
operation result code

◆ vlSocketShutdownLibrary()

void vlSocketShutdownLibrary ( void  )

Shuts down the process-wide socket subsystem.

On platforms where no explicit teardown is required, this function is a no-op.

Contract

  • Ownership: None.
  • Lifetime: Releases process-global socket resources as needed.
  • Thread Safety: Should not race with active socket creation or active socket use.
  • Nullability: N/A.
  • Error Conditions: None reported through the API.
  • Undefined Behavior: Calling while sockets are still in active use may cause backend-specific issues.
  • Memory Allocation Expectations: May release platform-managed resources.
  • Return-value Semantics: None (void).

◆ vlSocketStartup()

vl_socket_result vlSocketStartup ( void  )

Initializes the process-wide socket subsystem.

On platforms where no explicit socket startup is required, this function is a no-op that returns VL_SOCKET_SUCCESS.

On platforms that require initialization of the networking subsystem, this function must be called successfully before creating sockets.

Contract

  • Ownership: None.
  • Lifetime: Initializes process-global socket state as needed.
  • Thread Safety: Safe to call, but should generally be performed during application startup.
  • Nullability: N/A.
  • Error Conditions: Returns VL_SOCKET_ERROR_SYSTEM or VL_SOCKET_ERROR_NOT_INITIALIZED if platform startup fails.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: May allocate platform-managed resources.
  • Return-value Semantics: Returns VL_SOCKET_SUCCESS on success, otherwise an error code.
Returns
operation result code