XBEE_NETSTART

Section: Linux Programmer's Manual (3)
Updated: 04-Mar-2012
Index Return to Main Contents
 

NAME

xbee_netStart, xbee_netvStart, xbee_netStop  

SYNOPSIS

#include <xbee.h>

xbee_err xbee_netStart(struct xbee *xbee, int port, int(*clientFilter)(struct xbee *xbee, const char *remoteHost));

xbee_err xbee_netvStart(struct xbee *xbee, int fd, int(*clientFilter)(struct xbee *xbee, const char *remoteHost));

xbee_err xbee_netStop(struct xbee *xbee);  

DESCRIPTION

These functions allow you to start and stop the network interface for libxbee.

If you use xbee_netStart() libxbee will listen on all avaliable interfaces, you can only specify which port to listen on.

If you use xbee_netvStart() you must provide a file descriptor for a socket that has been bound to an interface and port - using socket(2) and bind(2) - but is not yet listening.

For both of these functions, you may specify a clientFilter that may decide if the client will be granted access, or denied. If the function returns 0, then the connection will be permitted, otherwise it will be terminated. See the example for more details.

If you wish to terminate the network interface before calling xbee_shutdown(3), you may use xbee_netStop(). If you do not call xbee_netStop() before xbee_shutdown(3), then libxbee will call it for you.  

Return Value

On success these functions will return XBEE_ENONE, otherwise an error number from enum xbee_errors (as specified in <xbee.h>)  

EXAMPLE

#include <xbee.h>

int myClientFilter(struct xbee *xbee, const char *remoteHost) {
        printf("Connection request from [%s]\n", remoteHost);
        return 0; /* return 0 - accept, anything else means deny  */
}

struct xbee *xbee;

/* initialize xbee, using xbee_setup() */

xbee_netStart(xbee, 27015, myClientFilter);

/* use the network interface... */

xbee_netStop(xbee);
 

AUTHOR

Attie Grande <attie@attie.co.uk>  

SEE ALSO

libxbee(3), xbee_setup(3), socket(2), bind(2)
 

Index

NAME
SYNOPSIS
DESCRIPTION
Return Value
EXAMPLE
AUTHOR
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 13:52:19 GMT, August 11, 2019