Create a Server Connection.
A ServerConnection object is normally used for accepting new connections for the web-server. It is possible to redirect new connections to the "userDefinedAccept" callback function. This makes it possible to use the socket dispatcher logic in the web-server for implementing other services such as a telnet server.
The "user defined accept" callback function is called when a new connection is established. The HttpConnection object passed in as the argument to the callback function is a temporary object that will be destroyed as soon as the callback function returns. You must, therefore, move the connection into an initialized application object.
static void MyHttpCon_dispatchData(
SoDispCon* socket)
{
MyHttpCon* o = (MyHttpCon*)socket;
char buf[512];
if(len < 0)
{
return;
}
if(len > 0)
{
}
}
{
MyHttpCon* o = (MyHttpCon*)
baMalloc(
sizeof(MyHttpCon));
(void)listener;
if(!o) return;
MyHttpCon_dispatchData);
}
#define HttpConnection_getServer(o)
Definition: HttpConnection.h:127
#define HttpConnection_getDispatcher(o)
Definition: HttpConnection.h:130
BA_API int HttpConnection_readData(HttpConnection *con, void *data, int len)
Read pending pushback bytes first, otherwise perform an event-oriented read.
BA_API int HttpConnection_moveCon(HttpConnection *o, HttpConnection *newCon)
Move the socket, transport state and pending input to another object.
BA_API void HttpConnection_constructor(HttpConnection *o, struct HttpServer *server, struct SoDisp *dispatcher, SoDispCon_DispRecEv e)
Initialize connection storage without opening a socket.
BA_API void HttpConnection_destructor(HttpConnection *o)
Release pushback storage, unregister events, and close the connection.
BA_API void SoDisp_activateRec(SoDisp *o, struct SoDispCon *con)
Enable receive events.
BA_API void SoDisp_addConnection(SoDisp *o, struct SoDispCon *con)
Register a connection without enabling events.
void * baMalloc(size_t size)
Allocate uninitialized storage using the target's configured allocator.
void baFree(void *p)
Release storage using the target's configured allocator.
Contains information about the physical socket connection.
Definition: HttpConnection.h:80
Create a server listen object.
Definition: HttpServCon.h:70
Contains information about the physical socket connection.
Definition: SoDispCon.h:120
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:91