Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
DOMAIN_SERVER(3)       FreeBSD Library Functions Manual	      DOMAIN_SERVER(3)

NAME
     domain_server -- generic DOMAIN server

LIBRARY
     PDEL Library (libpdel, -lpdel)

SYNOPSIS
     #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);

DESCRIPTION
     These functions provide support for implementing DOMAIN servers.

     domain_server_start() creates a new DOMAIN	server listening for connec-
     tions 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 si-
     multaneous	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 hav-
     ing 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	con-
     nection.  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 associ-
     ated 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.

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

SEE ALSO
     libpdel(3), pevent(3), typed_mem(3)

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

AUTHORS
     Archie Cobbs <archie@freebsd.org>
     Mark Gooderum <markpdel@jumpweb.com>

FreeBSD	13.0		       October 25, 2006			  FreeBSD 13.0

NAME | LIBRARY | SYNOPSIS | DESCRIPTION | RETURN VALUES | SEE ALSO | HISTORY | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=domain_server&sektion=3&manpath=FreeBSD+13.0-RELEASE+and+Ports>

home | help