BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

Data Structures

struct  pj_fd_set_t
 

Functions

void PJ_FD_ZERO (pj_fd_set_t *fdsetp)
 
pj_size_t PJ_FD_COUNT (const pj_fd_set_t *fdsetp)
 
void PJ_FD_SET (pj_sock_t fd, pj_fd_set_t *fdsetp)
 
void PJ_FD_CLR (pj_sock_t fd, pj_fd_set_t *fdsetp)
 
pj_bool_t PJ_FD_ISSET (pj_sock_t fd, const pj_fd_set_t *fdsetp)
 
int pj_sock_select (int n, pj_fd_set_t *readfds, pj_fd_set_t *writefds, pj_fd_set_t *exceptfds, const pj_time_val *timeout)
 

Detailed Description

This module provides portable abstraction for select() like API. The abstraction is needed so that it can utilize various event dispatching mechanisms that are available across platforms.

The API is very similar to normal select() usage.

Examples

For some examples on how to use the select API, please see:

Function Documentation

◆ PJ_FD_CLR()

void PJ_FD_CLR ( pj_sock_t  fd,
pj_fd_set_t fdsetp 
)

Remove the file descriptor fd from the set pointed to by fdsetp. If fd is not a member of this set, there shall be no effect on the set, nor will an error be returned.

Parameters
fdThe socket descriptor.
fdsetpThe descriptor set.

◆ PJ_FD_COUNT()

pj_size_t PJ_FD_COUNT ( const pj_fd_set_t fdsetp)

This is an internal function, application shouldn't use this.

Get the number of descriptors in the set. This is defined in sock_select.c This function will only return the number of sockets set from PJ_FD_SET operation. When the set is modified by other means (such as by select()), the count will not be reflected here.

Parameters
fdsetpThe descriptor set.
Returns
Number of descriptors in the set.

◆ PJ_FD_ISSET()

pj_bool_t PJ_FD_ISSET ( pj_sock_t  fd,
const pj_fd_set_t fdsetp 
)

Evaluate to non-zero if the file descriptor fd is a member of the set pointed to by fdsetp, and shall evaluate to zero otherwise.

Parameters
fdThe socket descriptor.
fdsetpThe descriptor set.
Returns
Nonzero if fd is member of the descriptor set.

◆ PJ_FD_SET()

void PJ_FD_SET ( pj_sock_t  fd,
pj_fd_set_t fdsetp 
)

Add the file descriptor fd to the set pointed to by fdsetp. If the file descriptor fd is already in this set, there shall be no effect on the set, nor will an error be returned.

Parameters
fdThe socket descriptor.
fdsetpThe descriptor set.

◆ PJ_FD_ZERO()

void PJ_FD_ZERO ( pj_fd_set_t fdsetp)

Initialize the descriptor set pointed to by fdsetp to the null set.

Parameters
fdsetpThe descriptor set.

◆ pj_sock_select()

int pj_sock_select ( int  n,
pj_fd_set_t readfds,
pj_fd_set_t writefds,
pj_fd_set_t exceptfds,
const pj_time_val timeout 
)

This function wait for a number of file descriptors to change status. The behaviour is the same as select() function call which appear in standard BSD socket libraries.

Parameters
nOn Unices, this specifies the highest-numbered descriptor in any of the three set, plus 1. On Windows, the value is ignored.
readfdsOptional pointer to a set of sockets to be checked for readability.
writefdsOptional pointer to a set of sockets to be checked for writability.
exceptfdsOptional pointer to a set of sockets to be checked for errors.
timeoutMaximum time for select to wait, or null for blocking operations.
Returns
The total number of socket handles that are ready, or zero if the time limit expired, or -1 if an error occurred.

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.