Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

SOFIAPUBFUN int su_wait_create ( su_wait_t newwait,
su_socket_t  socket,
int  events 

Create a wait object.

The function su_wait_create() creates a new su_wait_t object for an socket, with given events. The new wait object is assigned to the newwait parameter.

There can be only one wait object per socket. (This is a limitation or feature of WinSock interface; the limitation is not enforced on other platforms).

As a side-effect the socket is put into non-blocking mode when wait object is created.

newwaitthe newly created wait object (output)
eventsmask for events that can signal this wait object
Return values:
0if the call was successful,
-1upon an error.

Definition at line 132 of file su_wait.c.

References su_errno, su_seterrno(), and su_wait_create().

Referenced by assign_socket(), forwarder_accept(), init_test(), stun_obtain_shared_secret(), su_wait_create(), and tport_register_secondary().

  HANDLE h = WSACreateEvent();

  if (newwait == NULL || events == 0 || socket == INVALID_SOCKET) {
    return -1;

  *newwait = 0;

  if (WSAEventSelect(socket, h, events) != 0) {
    int error = su_errno();
    return -1;

  *newwait = h;

  int mode;

  if (newwait == NULL || events == 0 || socket == INVALID_SOCKET) {
    return -1;

  mode = fcntl(socket, F_GETFL, 0);
  if (mode < 0)
     return -1;
  mode |= O_NDELAY | O_NONBLOCK;
  if (fcntl(socket, F_SETFL, mode) < 0)
    return -1;

  newwait->fd = socket;
  newwait->events = events;
  newwait->revents = 0;

  return 0;

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index