ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
acip_transport_methods_t Struct Reference

Transport method table (virtual function table) More...

#include <include/ascii-chat/network/acip/transport.h>

Data Fields

asciichat_error_t(* send )(acip_transport_t *transport, const void *data, size_t len)
 Send data through this transport.
 
asciichat_error_t(* recv )(acip_transport_t *transport, void **buffer, size_t *out_len, void **out_allocated_buffer)
 Receive data from this transport.
 
asciichat_error_t(* close )(acip_transport_t *transport)
 Close this transport.
 
acip_transport_type_t(* get_type )(acip_transport_t *transport)
 Get transport type.
 
socket_t(* get_socket )(acip_transport_t *transport)
 Get underlying socket (if applicable)
 
bool(* is_connected )(acip_transport_t *transport)
 Check if transport is connected.
 
bool(* has_pending_data )(acip_transport_t *transport)
 Check whether the transport has pending readable data.
 
void(* destroy_impl )(acip_transport_t *transport)
 Custom destroy implementation (optional)
 

Detailed Description

Transport method table (virtual function table)

Each transport implementation provides these methods. ACIP protocol code calls these instead of socket functions.

Definition at line 115 of file transport.h.

Field Documentation

◆ close

asciichat_error_t(* acip_transport_methods_t::close) (acip_transport_t *transport)

Close this transport.

Parameters
transportTransport instance
Returns
ASCIICHAT_OK on success, error code on failure
Note
Should be idempotent (safe to call multiple times)
Does NOT free the transport structure itself

Definition at line 156 of file transport.h.

Referenced by acip_transport_destroy().

◆ destroy_impl

void(* acip_transport_methods_t::destroy_impl) (acip_transport_t *transport)

Custom destroy implementation (optional)

Parameters
transportTransport instance
Note
Called by acip_transport_destroy() before freeing impl_data
Should free transport-specific resources (peer connections, etc.)
May be NULL if no custom cleanup needed

Definition at line 205 of file transport.h.

Referenced by acip_transport_destroy().

◆ get_socket

socket_t(* acip_transport_methods_t::get_socket) (acip_transport_t *transport)

Get underlying socket (if applicable)

Parameters
transportTransport instance
Returns
Socket descriptor or INVALID_SOCKET_VALUE
Note
Returns INVALID_SOCKET_VALUE for transports without sockets
Useful for select()/poll() integration

Definition at line 175 of file transport.h.

Referenced by acip_client_receive_and_dispatch(), acip_server_receive_and_dispatch(), and server_connection_establish().

◆ get_type

acip_transport_type_t(* acip_transport_methods_t::get_type) (acip_transport_t *transport)

Get transport type.

Parameters
transportTransport instance
Returns
Transport type enum value

Definition at line 164 of file transport.h.

Referenced by acip_transport_destroy().

◆ has_pending_data

bool(* acip_transport_methods_t::has_pending_data) (acip_transport_t *transport)

Check whether the transport has pending readable data.

Parameters
transportTransport instance
Returns
true if data is ready to read, false otherwise
Note
This is a lightweight readiness hint, not a guarantee that recv() will succeed.

Definition at line 194 of file transport.h.

◆ is_connected

bool(* acip_transport_methods_t::is_connected) (acip_transport_t *transport)

Check if transport is connected.

Parameters
transportTransport instance
Returns
true if connected, false otherwise

Definition at line 183 of file transport.h.

Referenced by acip_client_receive_and_dispatch(), acip_server_receive_and_dispatch(), and acip_transport_destroy().

◆ recv

asciichat_error_t(* acip_transport_methods_t::recv) (acip_transport_t *transport, void **buffer, size_t *out_len, void **out_allocated_buffer)

Receive data from this transport.

Parameters
transportTransport instance
bufferOutput buffer (allocated by transport)
out_lenReceived data length
out_allocated_bufferBuffer to free (may differ from buffer)
Returns
ASCIICHAT_OK on success, error code on failure
Note
Allocates buffer, caller must free via out_allocated_buffer
May block until data arrives
For TCP: calls socket_recv_all()
For WebSocket: unwraps WebSocket frame

Definition at line 145 of file transport.h.

Referenced by acip_server_receive_and_dispatch(), and client_receive_thread().

◆ send

asciichat_error_t(* acip_transport_methods_t::send) (acip_transport_t *transport, const void *data, size_t len)

Send data through this transport.

Parameters
transportTransport instance
dataData to send (NOT owned by transport)
lenData length in bytes
Returns
ASCIICHAT_OK on success, error code on failure
Note
Does NOT take ownership of data buffer
May block until send completes
For TCP: calls socket_send_all()
For WebSocket: wraps in WebSocket frame

Definition at line 129 of file transport.h.


The documentation for this struct was generated from the following file: