Selector.h File Reference

#include <SFML/Config.h>
#include <SFML/Network/SocketTCP.h>
#include <SFML/Network/SocketUDP.h>

Go to the source code of this file.


Typedefs

typedef sfSelectorTCP sfSelectorTCP
 sfSelectorTCP and sfSelectorUDP allow reading from multiple sockets without blocking.
typedef sfSelectorUDP sfSelectorUDP

Functions

CSFML_API sfSelectorTCPsfSelectorTCP_Create ()
 Create a new selector.
CSFML_API sfSelectorUDPsfSelectorUDP_Create ()
CSFML_API void sfSelectorTCP_Destroy (sfSelectorTCP *Selector)
 Destroy an existing selector.
CSFML_API void sfSelectorUDP_Destroy (sfSelectorUDP *Selector)
CSFML_API void sfSelectorTCP_Add (sfSelectorTCP *Selector, sfSocketTCP *Socket)
 Add a socket to watch to a selector.
CSFML_API void sfSelectorUDP_Add (sfSelectorUDP *Selector, sfSocketUDP *Socket)
CSFML_API void sfSelectorTCP_Remove (sfSelectorTCP *Selector, sfSocketTCP *Socket)
 Remove a socket from a selector.
CSFML_API void sfSelectorUDP_Remove (sfSelectorUDP *Selector, sfSocketUDP *Socket)
CSFML_API void sfSelectorTCP_Clear (sfSelectorTCP *Selector)
 Remove all sockets from a selector.
CSFML_API void sfSelectorUDP_Clear (sfSelectorUDP *Selector)
CSFML_API unsigned int sfSelectorTCP_Wait (sfSelectorTCP *Selector, float Timeout)
 Wait and collect sockets which are ready for reading.
CSFML_API unsigned int sfSelectorUDP_Wait (sfSelectorUDP *Selector, float Timeout)
CSFML_API sfSocketTCPsfSelectorTCP_GetSocketReady (sfSelectorTCP *Selector, unsigned int Index)
 After a call to Wait(), get the Index-th socket which is ready for reading.
CSFML_API sfSocketUDPsfSelectorUDP_GetSocketReady (sfSelectorUDP *Selector, unsigned int Index)

Typedef Documentation

typedef struct sfSelectorTCP sfSelectorTCP

sfSelectorTCP and sfSelectorUDP allow reading from multiple sockets without blocking.

It's a kind of multiplexer

Definition at line 40 of file Selector.h.

typedef struct sfSelectorUDP sfSelectorUDP

Definition at line 41 of file Selector.h.


Function Documentation

CSFML_API void sfSelectorTCP_Add ( sfSelectorTCP Selector,
sfSocketTCP Socket 
)

Add a socket to watch to a selector.

Parameters:
Selector : Selector to add the socket to
Socket : Socket to add

CSFML_API void sfSelectorTCP_Clear ( sfSelectorTCP Selector  ) 

Remove all sockets from a selector.

Parameters:
Selector : Selector to remove the socket from

CSFML_API sfSelectorTCP* sfSelectorTCP_Create (  ) 

Create a new selector.

Returns:
A new sfSelector object

CSFML_API void sfSelectorTCP_Destroy ( sfSelectorTCP Selector  ) 

Destroy an existing selector.

Parameters:
Selector : Selector to delete

CSFML_API sfSocketTCP* sfSelectorTCP_GetSocketReady ( sfSelectorTCP Selector,
unsigned int  Index 
)

After a call to Wait(), get the Index-th socket which is ready for reading.

The total number of sockets ready is the integer returned by the previous call to Wait()

Parameters:
Selector : Selector to check
Index : Index of the socket to get
Returns:
The Index-th socket

CSFML_API void sfSelectorTCP_Remove ( sfSelectorTCP Selector,
sfSocketTCP Socket 
)

Remove a socket from a selector.

Parameters:
Selector : Selector to remove the socket from
Socket : Socket to remove

CSFML_API unsigned int sfSelectorTCP_Wait ( sfSelectorTCP Selector,
float  Timeout 
)

Wait and collect sockets which are ready for reading.

This functions will return either when at least one socket is ready, or when the given time is out

Parameters:
Selector : Selector to check
Timeout : Maximum time to wait, in seconds (0 to disable timeout)
Returns:
Number of sockets ready

CSFML_API void sfSelectorUDP_Add ( sfSelectorUDP Selector,
sfSocketUDP Socket 
)

CSFML_API void sfSelectorUDP_Clear ( sfSelectorUDP Selector  ) 

CSFML_API sfSelectorUDP* sfSelectorUDP_Create (  ) 

CSFML_API void sfSelectorUDP_Destroy ( sfSelectorUDP Selector  ) 

CSFML_API sfSocketUDP* sfSelectorUDP_GetSocketReady ( sfSelectorUDP Selector,
unsigned int  Index 
)

CSFML_API void sfSelectorUDP_Remove ( sfSelectorUDP Selector,
sfSocketUDP Socket 
)

CSFML_API unsigned int sfSelectorUDP_Wait ( sfSelectorUDP Selector,
float  Timeout 
)