GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
DOMAIN_SERVER(3) FreeBSD Library Functions Manual DOMAIN_SERVER(3)

domain_server
generic DOMAIN server

PDEL Library (libpdel, -lpdel)

#include <sys/types.h>
#include <sys/un.h>
#include <stdio.h>
#include <pdel/net/domain_server.h>

struct domain_server *
domain_server_start(struct pevent_ctx *ctx, void *cookie, const char *mtype, struct in_addr ip, u_int16_t port, u_int max_conn, u_int conn_timeout, domain_setup_t *setup, domain_handler_t *handler, domain_teardown_t *teardown);

void
domain_server_stop(struct domain_server **servp);

void *
domain_server_get_cookie(struct domain_server *serv);

struct domain_server *
domain_connection_get_server(struct domain_connection *conn);

void *
domain_connection_get_cookie(struct domain_connection *conn);

int
domain_connection_get_fd(struct domain_connection *conn);

FILE *
domain_connection_get_fp(struct domain_connection *conn);

void
domain_connection_get_peer(struct domain_connection *conn, struct sockaddr_un *sun);

These functions provide support for implementing DOMAIN servers.

domain_server_start() creates a new DOMAIN server listening for connections on IP address ip and port port. Memory for the domain_server is dynamically allocated with typed_mem(3) type mtype. At most max_conn simultaneous connections will be allowed. If conn_timeout is non-zero, then if an attempt to read from or write to a peer blocks for more than conn_timeout seconds, the connection will be terminated. ctx is a pevent(3) event context used to listen for incoming connections.

The setup, handler, and teardown arguments are pointers to functions having these types:

typedef void *domain_setup_t(struct domain_connection *conn);
typedef void domain_handler_t(struct domain_connection *conn);
typedef void domain_teardown_t(struct domain_connection *conn);

Each connection is represented by a domain_connection object. For each new connection, setup() is called to initialize user state for the connection. If setup is unsuccessful, setup() should return NULL and set errno appropriately, and the connection will be closed. Otherwise, it should return a non-NULL cookie; this cookie can be accessed later in handler() and teardown() by calling domain_connection_get_cookie().

handler() is used to service the connection. The thread calling this function may be canceled at any cancellation point; therefore, handler() may need to register cleanup hooks to clean up allocated resources should that happen.

teardown() is called when handler() returns, or the thread is canceled. If setup() returns successfully, teardown() is guaranteed to be called exactly once.

domain_server_stop() stops and destroys a domain_server. All existing connection threads are canceled and the current thread blocks until teardown() has been called for each connection.

domain_connection_get_peer() retrieves the peer's address.

domain_connection_get_server() returns the domain_server object associated with the connection conn.

domain_connection_get_fd() returns the DOMAIN socket associated with the connection.

domain_connection_get_fp() returns a stream opened on top of the socket for use with stream based I/O.

The user code should not close either the socket or the stream; these will be closed automatically when the connection is terminated.

domain_server_start() returns NULL to indicate an error, with errno set appropriately.

libpdel(3), pevent(3), typed_mem(3)

The PDEL library was developed at Packet Design, LLC. http://www.packetdesign.com/

Archie Cobbs ⟨archie@freebsd.org⟩
Mark Gooderum ⟨markpdel@jumpweb.com⟩
October 25, 2006 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.