su_wait.c File Reference


Detailed Description

Implementation of OS-independent socket synchronization interface.

This looks like nth reincarnation of "reactor". It implements the (poll()/select()/WaitForMultipleObjects()) functionality.

Author:
Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden>

Martti Mela <Martti.Mela@nokia-email.address.hidden>

Date:
Created: Tue Sep 14 15:51:04 1999 ppessi

#include "config.h"
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include "sofia-sip/su.h"
#include "sofia-sip/su_wait.h"
#include "sofia-sip/su_alloc.h"

Include dependency graph for su_wait.c:

Functions

void su_wait_init (su_wait_t dst[1])
 Initialize a wait object.
int su_wait_create (su_wait_t *newwait, su_socket_t socket, int events)
 Create a wait object.
int su_wait_destroy (su_wait_t *waitobj)
 Destroy a wait object.
int su_wait (su_wait_t waits[], unsigned n, su_duration_t timeout)
 Wait for multiple events.
int su_wait_events (su_wait_t *waitobj, su_socket_t s)
 Get events.
int su_wait_mask (su_wait_t *waitobj, su_socket_t s, int events)
 Set event mask.


Function Documentation

int su_wait ( su_wait_t  waits[],
unsigned  n,
su_duration_t  timeout 
)

Wait for multiple events.

The function su_wait() blocks until an event specified by wait objects in wait array. If timeout is not SU_WAIT_FOREVER, a timeout occurs after timeout milliseconds.

In Unix, this is poll() or select().

In Windows, this is WSAWaitForMultipleEvents().

Parameters:
waits array of wait objects
n number of wait objects in array waits
timeout timeout in milliseconds
Return values:
Index of the signaled wait object, if any,
SU_WAIT_TIMEOUT if timeout occurred, or
-1 upon an error.

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.

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

int su_wait_destroy ( su_wait_t waitobj  ) 

Destroy a wait object.

The function su_wait_destroy() destroys a su_wait_t object.

Parameters:
waitobj pointer to wait object
Return values:
0 when successful,
-1 upon an error.

int su_wait_events ( su_wait_t waitobj,
su_socket_t  s 
)

Get events.

The function su_wait_events() returns an mask describing events occurred.

Parameters:
waitobj pointer to wait object
s socket
Returns:
Binary mask describing the events.

void su_wait_init ( su_wait_t  dst[1]  ) 

Initialize a wait object.

The function su_wait_init initializes a memory area of a su_wait_t object.

int su_wait_mask ( su_wait_t waitobj,
su_socket_t  s,
int  events 
)

Set event mask.

The function su_wait_mask() sets the mask describing events that can signal the wait object.

Parameters:
waitobj pointer to wait object
s socket
events new event mask
Return values:
0 when successful,
-1 upon an error.


Sofia-SIP 1.12.6work - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.