|
Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
|
Declares the native connection abstraction and transport metadata helpers. More...
#include <signal.h>#include <stddef.h>Go to the source code of this file.
Data Structures | |
| struct | NativeConnection |
| Accepted client connection and its resolved transport metadata. More... | |
Enumerations | |
| enum | NativeTransportType { NATIVE_TRANSPORT_UNKNOWN = 0 , NATIVE_TRANSPORT_TCP = 1 , NATIVE_TRANSPORT_UNIX = 2 } |
| Transport type used by a native connection. More... | |
Functions | |
Native connection helpers | |
| void | native_connection_init (NativeConnection *connection) |
| Initializes a native connection record to an empty state. | |
| void | native_connection_reset (NativeConnection *connection) |
| Releases owned transport metadata and resets a connection record. | |
| int | native_connection_accept_next (int server_fd, volatile sig_atomic_t *shutdown_requested, NativeConnection *connection) |
| Accepts the next client connection and records its transport metadata. | |
| int | native_connection_read (NativeConnection *connection, void *buffer, size_t len) |
| Reads bytes from a native connection. | |
| int | native_connection_write (NativeConnection *connection, const void *buffer, size_t len) |
| Writes bytes to a native connection. | |
| int | native_connection_flush (NativeConnection *connection) |
| Flushes any buffered connection output when the transport requires it. | |
| int | native_connection_close (NativeConnection *connection) |
| Closes a native connection and releases its owned metadata. | |
| int | native_connection_shutdown (NativeConnection *connection) |
| Shuts down a native connection without discarding the record itself. | |
| const char * | native_connection_peer_info (const NativeConnection *connection) |
| Returns the printable remote endpoint description for a connection. | |
| const char * | native_connection_local_info (const NativeConnection *connection) |
| Returns the printable local endpoint description for a connection. | |
| NativeTransportType | native_connection_transport_type (const NativeConnection *connection) |
| Returns the resolved transport type for a connection. | |
| const char * | native_connection_transport_type_name (const NativeConnection *connection) |
| Returns a human-readable transport type name for a connection. | |
Declares the native connection abstraction and transport metadata helpers.
Definition in file native_connection.h.
| enum NativeTransportType |
Transport type used by a native connection.
| Enumerator | |
|---|---|
| NATIVE_TRANSPORT_UNKNOWN | Transport metadata is not yet known. |
| NATIVE_TRANSPORT_TCP | Connection is backed by a TCP socket. |
| NATIVE_TRANSPORT_UNIX | Connection is backed by a Unix domain socket. |
Definition at line 15 of file native_connection.h.
| int native_connection_accept_next | ( | int | server_fd, |
| volatile sig_atomic_t * | shutdown_requested, | ||
| NativeConnection * | connection ) |
Accepts the next client connection and records its transport metadata.
| server_fd | Listening socket descriptor. |
| shutdown_requested | Shared shutdown flag checked while accepting. |
| connection | Destination connection record. |
Definition at line 148 of file native_connection.c.
References NativeConnection::fd, native_connection_apply_timeouts(), native_connection_close_socket, native_connection_detect_transport(), native_connection_populate_endpoint_info(), native_connection_reset(), and NativeConnection::transport_type.
Referenced by accept_http_request_native().
| int native_connection_close | ( | NativeConnection * | connection | ) |
Closes a native connection and releases its owned metadata.
| connection | Connection to close. |
Definition at line 207 of file native_connection.c.
References NativeConnection::fd, native_connection_close_socket, and native_connection_reset().
Referenced by accept_http_request_native(), build_worker_context_native(), free_worker_context_native(), serve_runtime_stack_native(), serve_single_app(), and serve_static_root().
| int native_connection_flush | ( | NativeConnection * | connection | ) |
Flushes any buffered connection output when the transport requires it.
| connection | Connection to flush. |
Definition at line 202 of file native_connection.c.
| void native_connection_init | ( | NativeConnection * | connection | ) |
Initializes a native connection record to an empty state.
| connection | Connection record to initialize. |
Definition at line 126 of file native_connection.c.
References NativeConnection::fd, NativeConnection::local_info, NATIVE_TRANSPORT_UNKNOWN, NativeConnection::peer_info, and NativeConnection::transport_type.
Referenced by build_worker_context_native(), serve_runtime_stack_native(), serve_single_app(), and serve_static_root().
| const char * native_connection_local_info | ( | const NativeConnection * | connection | ) |
Returns the printable local endpoint description for a connection.
| connection | Connection to inspect. |
Definition at line 230 of file native_connection.c.
References NativeConnection::local_info.
| const char * native_connection_peer_info | ( | const NativeConnection * | connection | ) |
Returns the printable remote endpoint description for a connection.
| connection | Connection to inspect. |
Definition at line 226 of file native_connection.c.
References NativeConnection::peer_info.
| int native_connection_read | ( | NativeConnection * | connection, |
| void * | buffer, | ||
| size_t | len ) |
Reads bytes from a native connection.
| connection | Open connection to read from. |
| buffer | Destination buffer. |
| len | Maximum number of bytes to read. |
Definition at line 180 of file native_connection.c.
References NativeConnection::fd, len, and native_connection_recv.
Referenced by native_spool_request_body_to_temp_file(), and parse_http_request_native().
| void native_connection_reset | ( | NativeConnection * | connection | ) |
Releases owned transport metadata and resets a connection record.
| connection | Connection record to clear. |
Definition at line 136 of file native_connection.c.
References NativeConnection::fd, NativeConnection::local_info, NATIVE_TRANSPORT_UNKNOWN, NativeConnection::peer_info, and NativeConnection::transport_type.
Referenced by native_connection_accept_next(), and native_connection_close().
| int native_connection_shutdown | ( | NativeConnection * | connection | ) |
Shuts down a native connection without discarding the record itself.
| connection | Connection to shut down. |
Definition at line 219 of file native_connection.c.
References NativeConnection::fd, and native_connection_shutdown_socket.
| NativeTransportType native_connection_transport_type | ( | const NativeConnection * | connection | ) |
Returns the resolved transport type for a connection.
| connection | Connection to inspect. |
Definition at line 234 of file native_connection.c.
References NATIVE_TRANSPORT_UNKNOWN, and NativeConnection::transport_type.
Referenced by native_connection_transport_type_name().
| const char * native_connection_transport_type_name | ( | const NativeConnection * | connection | ) |
Returns a human-readable transport type name for a connection.
| connection | Connection to inspect. |
Definition at line 238 of file native_connection.c.
References native_connection_transport_type(), NATIVE_TRANSPORT_TCP, and NATIVE_TRANSPORT_UNIX.
| int native_connection_write | ( | NativeConnection * | connection, |
| const void * | buffer, | ||
| size_t | len ) |
Writes bytes to a native connection.
| connection | Open connection to write to. |
| buffer | Source bytes to send. |
| len | Number of bytes to send. |
Definition at line 187 of file native_connection.c.
References NativeConnection::fd, len, and native_connection_send.
Referenced by handle_app_or_runtime_request(), native_connection_printf(), native_dynamic_media_serve_asset(), and native_serve_static_file().