Xiqual 0.9.1

In file xinet/net_server.c:

SelectServer* net_server

(ulong tag1, ... )

Create a new select() server.

Documentation

Create a new select() server. All parameters are passed in as a taglist. To create a simple server for no more than 8 connections, at port 1242, calling client_read() to process each incoming message:

SelectServer *server;

server = net_create_server(XN_NUMCONNECTIONS, 16, XN_TIMEOUT_S, 1, XN_PORT, 1242, XN_READ_FUNC, client_read, TAG_END);

The accepted tags for this function are as follows:

XN_NUMCONNECTIONS: Maximum number of connection nodes to make available. Clients will get an XIPKT_FULL message when there are no more connections allowed, unless the onserverfull() hook is installed.

XN_TIMEOUT_S: Timeout in seconds before select() returns.

XN_TIMEOUT_MS: As above, but milliseconds - 10ms being the lowest you can safely expect to work.

XN_PORT: Port to wait for connections on.

XN_LINGER: Number of seconds for sockets to linger after closing. If a socket doesn't have the linger setting activated, it may take up to 5 minutes before the operating system releases all resources properly.

XN_CONNECT_FUNC: Hook called right after connection.

XN_CLOSE_FUNC: Hook called just before shutting down a socket.

XN_READ_FUNC: Hook called to read incoming messages. There is no default reader in libxinet yet.

XN_SERVERFULL_FUNC: If this is installed, you're responsible for the appropriate response to a server full condition. This could possibly be used to allocate more client nodes.

XN_QUEUE: Maximum listen() queue. Defaults to 5.

XN_COMMANDS: Array of text commands and a corresponding function to handle each. End the array with a NULL entry.

The function prototype is as follows: void functionname(SelectServer *server, int socket);

Parameters:
tags - Tags defining all server settings.
Returns:
A pointer to a valid SelectServer structure, with sockets able to listen().
Author:
Ronny Bangsund
See Also:
SelectServer, listen(), net_process(), xipacket, net_server_free()

Alphabetic index



This page was generated with the help of DOC++.