|
Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
|


Go to the source code of this file.
Classes | |
| struct | SoDispCon |
| Contains information about the physical socket connection. More... | |
Macros | |
| #define | SoDispCon_socketHasNonBlockData(o) (((o)->dataBits & SoDispCon_socketHasNonBlockDataBitMask) ? TRUE : FALSE) |
| #define | SoDispCon_hasMoreData(o) (((o)->dataBits & SoDispCon_hasMoreDataDataBitMask) ? TRUE : FALSE) |
| #define | SoDispCon_dispatcherHasCon(o) (((o)->dataBits & SoDispCon_dispatcherHasConDataBitMask)?TRUE:FALSE) |
| #define | SoDispCon_recEvActive(o) (((o)->dataBits & SoDispCon_recEvActiveDataBitMask)?TRUE:FALSE) |
| #define | SoDispCon_sendEvActive(o) (((o)->dataBits & SoDispCon_sendEvActiveDataBitMask)?TRUE:FALSE) |
| #define | SoDispCon_isNonBlocking(o) (((o)->dataBits & SoDispCon_isNonBlockingDataBitMask) ? TRUE : FALSE) |
| #define | SoDispCon_isIP6(o) (((o)->dataBits & SoDispCon_IP6DataBitMask) ? TRUE : FALSE) |
| #define | SoDispCon_isDGRAM(o) (((o)->dataBits & SoDispCon_DGramBitMask) ? TRUE : FALSE) |
| #define | SoDispCon_isSecure(o) ((o)->exec(o,0,SoDispCon_GetSharkSslCon,0,0) > 0) |
| Test a successfully installed transport for TLS. More... | |
| #define | SoDispCon_getSharkSslCon(o, sharkSslConPtrPtr) (o)->exec(o,0,SoDispCon_GetSharkSslCon,sharkSslConPtrPtr,0) |
| Inspect a successfully installed transport. More... | |
| #define | SoDispCon_isValid(o) HttpSocket_isValid(&(o)->httpSocket) |
| #define | SoDispCon_getDispatcher(o) (o)->dispatcher |
| #define | SoDispCon_setDispSendEvent(o, dispSendEvFp) (o)->dispSendEv=dispSendEvFp |
| Install the send-ready callback before enabling events. More... | |
| #define | SoDispCon_setDispRecEvent(o, dispRecEvFp) (o)->dispRecEv=dispRecEvFp |
| Install the receive callback before enabling events. More... | |
| #define | SoDispCon_readData(o, data, len, relmutex) |
| Read through the installed transport using its recorded readiness. More... | |
| #define | SoDispCon_asyncReady(o) (o)->exec(o,0,SoDispCon_ExTypeAsyncReady,0,0) |
| Advance any pending asynchronous send without modifying its payload. More... | |
| #define | SoDispCon_asyncSend(o, len) (o)->exec(o,0,SoDispCon_ExTypeAsyncReady,0,len) |
| Begin or advance a send from the transport's asynchronous buffer. More... | |
| #define | SoDispCon_destructor(o) SoDispCon_zzCloseCon(o,1) |
| Shut down and close the socket, disable events and remove registration. More... | |
| #define | SoDispCon_hardClose(o) SoDispCon_zzCloseCon(o, 2) |
| Abortively close the socket, disable events and remove registration. More... | |
| #define | SoDispCon_shutdown(o) SoDispCon_zzCloseCon(o, 1) |
| Shut down and close the socket, disable events and remove registration. More... | |
| #define | SoDispCon_closeCon(o) SoDispCon_zzCloseCon(o, 0) |
| Close the socket, disable events and remove registration. More... | |
| #define | SoDispCon_setReadTmo(o, timeout) (o)->rtmo = (U16)((timeout)/50) |
| Set the read wait timeout used by supported socket ports. More... | |
| #define | SoDispCon_getId(o) HttpSocket_getId(&(o)->httpSocket) |
Typedefs | |
| typedef void(* | SoDispCon_DispRecEv) (struct SoDispCon *con) |
| Dispatcher receive notification, invoked with its mutex held. More... | |
| typedef void(* | SoDispCon_DispSendEv) (struct SoDispCon *con) |
| Dispatcher send-ready notification, invoked with its mutex held. More... | |
| typedef struct SoDispCon | SoDispCon |
| Contains information about the physical socket connection. More... | |
Functions | |
| BA_API int | SoDispCon_getSharkAlert (SoDispCon *o, U8 *alertLevel, U8 *alertDescription) |
| Read the current SharkSSL alert fields. More... | |
| BA_API void | SoDispCon_constructor (SoDispCon *o, struct SoDisp *dispatcher, SoDispCon_DispRecEv e) |
| Initialize an empty connection without opening a socket. More... | |
| BA_API int | SoDispCon_blockRead (SoDispCon *o, void *data, int len) |
| Wait for input using a blocking connection. More... | |
| BA_API int | SoDispCon_sendData (SoDispCon *o, const void *data, int len) |
| Send an entire buffer through the installed transport. More... | |
| BA_API int | SoDispCon_sendDataNT (SoDispCon *o, const void *data, int len) |
| Send all bytes with the sendData contract, but omit body tracing. More... | |
| BA_API int | SoDispCon_sendDataX (SoDispCon *o, const void *data, int len) |
| Send all bytes without releasing the dispatcher mutex. More... | |
| BA_API int | SoDispCon_sendChunkData (SoDispCon *o, const void *data, int len) |
| Send one HTTP chunk, including its hexadecimal size and CRLF delimiters. More... | |
| BA_API int | SoDispCon_asyncReadyF (SoDispCon *o) |
| Advance asynchronous sending; same status contract as SoDispCon_asyncReady. More... | |
| BA_API void * | SoDispCon_allocAsynchBuf (SoDispCon *o, int *size) |
| Obtain transport-owned writable storage for asynchronous sending. More... | |
| BA_API int | SoDispCon_setNonblocking (SoDispCon *o) |
| Select nonblocking socket mode. More... | |
| BA_API int | SoDispCon_setBlocking (SoDispCon *o) |
| Select blocking socket mode. More... | |
| BA_API int | SoDispCon_moveCon (SoDispCon *o, SoDispCon *newCon) |
| Move socket and transport ownership without copying object storage. More... | |
| BA_API void | SoDispCon_setTCPNoDelay (SoDispCon *o, int enable) |
| Disable the TCP delay. More... | |
| BA_API int | SoDispCon_getPeerName (SoDispCon *o, HttpSockaddr *addr, U16 *port) |
| Read the remote peer endpoint. More... | |
| BA_API int | SoDispCon_getSockName (SoDispCon *o, HttpSockaddr *addr, U16 *port) |
| Read the local socket endpoint. More... | |
| BA_API char * | SoDispCon_addr2String (SoDispCon *o, HttpSockaddr *addr, char *buf, int len) |
| Format a numeric address without a port number. More... | |
| BA_API BaBool | SoDispCon_cmpAddr (SoDispCon *o, HttpSockaddr *addr2) |
| Compare an address with the current peer address, ignoring port numbers. More... | |
| BA_API int | SoDispCon_connect (SoDispCon *o, const char *host, U16 port, const void *bindIntfName, U16 bindPort, U32 timeout, BaBool dgram, BaBool ipv6, char **errinfo) |
| Connect an initialized, empty connection to a remote endpoint. More... | |
| BA_API int | SoDispCon_asyncConnect (SoDispCon *o, const char *host, U16 port, const void *bindIntfName, BaBool ipv6, char **errinfo) |
| Begin a TCP connection without waiting for TCP establishment. More... | |
| BA_API int | SoDispCon_asyncConnectNext (SoDispCon *o) |
| Try the next resolved address after a failed pending connection. More... | |
| #define SoDispCon_asyncReady | ( | o | ) | (o)->exec(o,0,SoDispCon_ExTypeAsyncReady,0,0) |
Advance any pending asynchronous send without modifying its payload.
| [in,out] | o | Connected object with an allocated asynchronous buffer. |
| #define SoDispCon_asyncSend | ( | o, | |
| len | |||
| ) | (o)->exec(o,0,SoDispCon_ExTypeAsyncReady,0,len) |
Begin or advance a send from the transport's asynchronous buffer.
| [in] | len | Positive payload byte count within the capacity returned by allocAsynchBuf for a new send. Do not alter the buffer until completion; use asyncReady to continue a pending send. |
| [in,out] | o | Connected object with an allocated asynchronous buffer. |
| #define SoDispCon_closeCon | ( | o | ) | SoDispCon_zzCloseCon(o, 0) |
Close the socket, disable events and remove registration.
| [in,out] | o | Initialized connection. Does not free object storage. No close result is reported; transport-owned buffers are invalidated. |
| #define SoDispCon_destructor | ( | o | ) | SoDispCon_zzCloseCon(o,1) |
Shut down and close the socket, disable events and remove registration.
| [in,out] | o | Initialized connection. Does not free object storage. No close result is reported; transport-owned buffers are invalidated. |
| #define SoDispCon_dispatcherHasCon | ( | o | ) | (((o)->dataBits & SoDispCon_dispatcherHasConDataBitMask)?TRUE:FALSE) |
| [in] | o | Initialized connection. |
| #define SoDispCon_getDispatcher | ( | o | ) | (o)->dispatcher |
| [in] | o | Initialized connection. |
| #define SoDispCon_getId | ( | o | ) | HttpSocket_getId(&(o)->httpSocket) |
| [in] | o | Initialized connection. |
| #define SoDispCon_getSharkSslCon | ( | o, | |
| sharkSslConPtrPtr | |||
| ) | (o)->exec(o,0,SoDispCon_GetSharkSslCon,sharkSslConPtrPtr,0) |
Inspect a successfully installed transport.
| [in] | o | Connected object with a valid transport implementation. |
| [out] | sharkSslConPtrPtr | Optional SharkSslCon** output, borrowed on success; NULL requests only the secure-transport test. |
| #define SoDispCon_hardClose | ( | o | ) | SoDispCon_zzCloseCon(o, 2) |
Abortively close the socket, disable events and remove registration.
| [in,out] | o | Initialized connection. Does not free object storage. No close result is reported; transport-owned buffers are invalidated. |
| #define SoDispCon_hasMoreData | ( | o | ) | (((o)->dataBits & SoDispCon_hasMoreDataDataBitMask) ? TRUE : FALSE) |
| [in] | o | Initialized connection. |
| #define SoDispCon_isDGRAM | ( | o | ) | (((o)->dataBits & SoDispCon_DGramBitMask) ? TRUE : FALSE) |
| [in] | o | Initialized connection. |
| #define SoDispCon_isIP6 | ( | o | ) | (((o)->dataBits & SoDispCon_IP6DataBitMask) ? TRUE : FALSE) |
| [in] | o | Initialized connection. |
| #define SoDispCon_isNonBlocking | ( | o | ) | (((o)->dataBits & SoDispCon_isNonBlockingDataBitMask) ? TRUE : FALSE) |
| [in] | o | Initialized connection. |
| #define SoDispCon_isSecure | ( | o | ) | ((o)->exec(o,0,SoDispCon_GetSharkSslCon,0,0) > 0) |
Test a successfully installed transport for TLS.
| [in] | o | Connected object with an installed transport. |
| #define SoDispCon_isValid | ( | o | ) | HttpSocket_isValid(&(o)->httpSocket) |
| [in] | o | Initialized connection. |
| #define SoDispCon_readData | ( | o, | |
| data, | |||
| len, | |||
| relmutex | |||
| ) |
Read through the installed transport using its recorded readiness.
| [out] | data | Required writable buffer; returned bytes are not NUL-terminated. |
| [in] | len | Positive capacity in bytes. |
| [in] | relmutex | True allows the transport to release the owned dispatcher mutex while waiting, then reacquire it; false (default) keeps it held. |
| [in,out] | o | Connected object with an installed transport. |
| #define SoDispCon_recEvActive | ( | o | ) | (((o)->dataBits & SoDispCon_recEvActiveDataBitMask)?TRUE:FALSE) |
| [in] | o | Initialized connection. |
| #define SoDispCon_sendEvActive | ( | o | ) | (((o)->dataBits & SoDispCon_sendEvActiveDataBitMask)?TRUE:FALSE) |
| [in] | o | Initialized connection. |
| #define SoDispCon_setDispRecEvent | ( | o, | |
| dispRecEvFp | |||
| ) | (o)->dispRecEv=dispRecEvFp |
Install the receive callback before enabling events.
| [in,out] | o | Initialized connection. |
| [in] | dispRecEvFp | Required callback while receive events are active. |
| #define SoDispCon_setDispSendEvent | ( | o, | |
| dispSendEvFp | |||
| ) | (o)->dispSendEv=dispSendEvFp |
Install the send-ready callback before enabling events.
| [in,out] | o | Initialized connection. |
| [in] | dispSendEvFp | Required callback while send events are active. |
| #define SoDispCon_setReadTmo | ( | o, | |
| timeout | |||
| ) | (o)->rtmo = (U16)((timeout)/50) |
Set the read wait timeout used by supported socket ports.
| [in,out] | o | Connected object. |
| [in] | timeout | Nonnegative integer milliseconds, at most 3276750. Stored as U16 units of 50 ms, rounding down; values below 50 disable the timeout. Zero means no timeout. Some read paths consume/reset the setting; SoDispCon_blockRead restores it during its internal TLS retries. |
| #define SoDispCon_shutdown | ( | o | ) | SoDispCon_zzCloseCon(o, 1) |
Shut down and close the socket, disable events and remove registration.
| [in,out] | o | Initialized connection. Does not free object storage. No close result is reported; transport-owned buffers are invalidated. |
| #define SoDispCon_socketHasNonBlockData | ( | o | ) | (((o)->dataBits & SoDispCon_socketHasNonBlockDataBitMask) ? TRUE : FALSE) |
| [in] | o | Initialized connection. |
Contains information about the physical socket connection.
This object is used internally by HttpServer when sending and receiving data on either an insecure or secure SSL connection.
| typedef void(* SoDispCon_DispRecEv) (struct SoDispCon *con) |
Dispatcher receive notification, invoked with its mutex held.
| [in,out] | con | Borrowed registered connection. Check operation results; readiness does not guarantee successful I/O. Stop events before freeing it. |
| typedef void(* SoDispCon_DispSendEv) (struct SoDispCon *con) |
Dispatcher send-ready notification, invoked with its mutex held.
| [in,out] | con | Borrowed registered connection. Check operation results; readiness does not guarantee successful I/O. Stop events before freeing it. |
| BA_API char * SoDispCon_addr2String | ( | SoDispCon * | o, |
| HttpSockaddr * | addr, | ||
| char * | buf, | ||
| int | len | ||
| ) |
Format a numeric address without a port number.
| [in] | addr | Required address with the same family as this connection. |
| [out] | buf | Required writable storage for a NUL-terminated result. |
| [in] | len | Capacity in bytes including NUL; at least 16 for IPv4 or 46 for IPv6. Always provide writable storage even if capacity is rejected. |
| [in,out] | o | Initialized connection. |
| BA_API void * SoDispCon_allocAsynchBuf | ( | SoDispCon * | o, |
| int * | size | ||
| ) |
Obtain transport-owned writable storage for asynchronous sending.
| [in,out] | size | Required positive requested capacity in bytes; receives the actual capacity, which may differ. Always use the returned capacity. |
| [in,out] | o | Initialized connection. |
| BA_API int SoDispCon_asyncConnect | ( | SoDispCon * | o, |
| const char * | host, | ||
| U16 | port, | ||
| const void * | bindIntfName, | ||
| BaBool | ipv6, | ||
| char ** | errinfo | ||
| ) |
Begin a TCP connection without waiting for TCP establishment.
DNS resolution can still block. Available unless NO_ASYNCH_RESP is defined.
| [in,out] | o | Initialized empty connection with no transport buffer/TLS state. Keep it alive until the attempt completes or is cleaned up. |
| [in] | host | Required NUL-terminated hostname or numeric address. |
| [in] | port | Remote port in host byte order, 1..65535. |
| [in] | bindIntfName | Borrowed local interface/address, or NULL for default; copied when the resolver keeps state for additional address attempts. |
| [in] | ipv6 | TRUE requests IPv6, FALSE IPv4. |
| [out] | errinfo | Optional borrowed resolver-text output, initially NULL. |
| BA_API int SoDispCon_asyncConnectNext | ( | SoDispCon * | o | ) |
Try the next resolved address after a failed pending connection.
| [in,out] | o | Connection with live USE_ADDRINFO pending-connect state. Call only after the current attempt fails; do not use as a readiness poll. |
| BA_API int SoDispCon_asyncReadyF | ( | SoDispCon * | o | ) |
Advance asynchronous sending; same status contract as SoDispCon_asyncReady.
| [in,out] | o | Connected object with an allocated asynchronous buffer. |
| BA_API int SoDispCon_blockRead | ( | SoDispCon * | o, |
| void * | data, | ||
| int | len | ||
| ) |
Wait for input using a blocking connection.
| [in,out] | o | Connected object in blocking mode; no competing reader. |
| [out] | data | Required writable storage, not NUL-terminated on return. |
| [in] | len | Positive capacity in bytes. |
Compare an address with the current peer address, ignoring port numbers.
| [in] | addr2 | Required address to compare; IPv4-mapped IPv6 is recognized. |
| [in,out] | o | Initialized connection. |
| BA_API int SoDispCon_connect | ( | SoDispCon * | o, |
| const char * | host, | ||
| U16 | port, | ||
| const void * | bindIntfName, | ||
| U16 | bindPort, | ||
| U32 | timeout, | ||
| BaBool | dgram, | ||
| BaBool | ipv6, | ||
| char ** | errinfo | ||
| ) |
Connect an initialized, empty connection to a remote endpoint.
| [in] | host | Required NUL-terminated hostname or numeric IP address. |
| [in] | port | Remote TCP/UDP port in host byte order, 1..65535. |
| [in] | bindIntfName | Optional borrowed platform local interface/address used during the call; NULL selects the default. |
| [in] | bindPort | Local port in host byte order; zero lets the OS choose. |
| [in] | timeout | Positive connect timeout in milliseconds, default 1500. The legacy resolver path ignores this value; USE_ADDRINFO applies it to individual address attempts, not the entire DNS-and-connect operation. |
| [in] | dgram | TRUE selects UDP, FALSE TCP (default). |
| [in] | ipv6 | TRUE requests IPv6, FALSE IPv4 (default); resolution depends on the selected network port. |
| [out] | errinfo | Optional output for borrowed platform resolver text; initialized to NULL. Do not free it or rely on text as a stable error code. |
| [in,out] | o | Initialized empty connection. |
| BA_API void SoDispCon_constructor | ( | SoDispCon * | o, |
| struct SoDisp * | dispatcher, | ||
| SoDispCon_DispRecEv | e | ||
| ) |
Initialize an empty connection without opening a socket.
| [out] | o | Caller-owned storage. |
| [in] | dispatcher | Borrowed dispatcher, or NULL for independent use. |
| [in] | e | Receive callback, required before enabling receive events. Install a transport by connecting or moving in an accepted connection. |
Read the remote peer endpoint.
| [out] | addr | Required address output, valid only on success. |
| [out] | port | Optional port output in host byte order; NULL omits it. |
| [in,out] | o | Initialized connection. |
Read the current SharkSSL alert fields.
| [in] | o | Connection known to use SharkSSL, not a plain socket with an asynchronous buffer or a pending connect operation. |
| [out] | alertLevel | Required U8 output, valid on success. |
| [out] | alertDescription | Required U8 output, valid on success. |
Read the local socket endpoint.
| [out] | addr | Required address output, valid only on success. |
| [out] | port | Optional port output in host byte order; NULL omits it. |
| [in,out] | o | Initialized connection. |
Move socket and transport ownership without copying object storage.
| [in,out] | o | Source connection; receive/send events are deactivated and it is removed from dispatcher registration during the move. |
| [in,out] | newCon | Initialized empty destination with dispatcher and event callbacks already configured. Do not overwrite a live destination socket. |
| BA_API int SoDispCon_sendChunkData | ( | SoDispCon * | o, |
| const void * | data, | ||
| int | len | ||
| ) |
Send one HTTP chunk, including its hexadecimal size and CRLF delimiters.
| [in] | data | Borrowed source containing len readable bytes. |
| [in] | len | Byte count from 0 through 65535. Zero sends the final empty chunk. |
| [in,out] | o | Initialized connection. |
| BA_API int SoDispCon_sendData | ( | SoDispCon * | o, |
| const void * | data, | ||
| int | len | ||
| ) |
Send an entire buffer through the installed transport.
| [in] | data | Borrowed source containing len readable bytes. |
| [in] | len | Nonnegative byte count. |
| [in,out] | o | Initialized connection. |
| BA_API int SoDispCon_sendDataNT | ( | SoDispCon * | o, |
| const void * | data, | ||
| int | len | ||
| ) |
Send all bytes with the sendData contract, but omit body tracing.
| [in,out] | o | Connected object. |
| [in] | data | Borrowed source containing len bytes. |
| [in] | len | Nonnegative byte count. |
| BA_API int SoDispCon_sendDataX | ( | SoDispCon * | o, |
| const void * | data, | ||
| int | len | ||
| ) |
Send all bytes without releasing the dispatcher mutex.
| [in,out] | o | Connected object; caller manages synchronization. |
| [in] | data | Borrowed source containing len readable bytes. |
| [in] | len | Nonnegative byte count. |
| BA_API int SoDispCon_setBlocking | ( | SoDispCon * | o | ) |
Select blocking socket mode.
| [in,out] | o | Initialized connection. |
| BA_API int SoDispCon_setNonblocking | ( | SoDispCon * | o | ) |
Select nonblocking socket mode.
| [in,out] | o | Initialized connection. |
| BA_API void SoDispCon_setTCPNoDelay | ( | SoDispCon * | o, |
| int | enable | ||
| ) |
Disable the TCP delay.
What TCP normally does is queue up data so it only sends full packets out when possible. (This is called Nagle's algorithm.) Call this function if you do not want that behavior.
| [in] | enable | True disables Nagle; false enables it. No socket-option error status is returned; errors can be traced. |
| [in,out] | o | Initialized connection. |