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