CSFML 2.6.1

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

Loading...
Searching...
No Matches
Functions
SocketSelector.h File Reference
`#include <SFML/Network/Export.h>`
`#include <SFML/Network/Types.h>`
`#include <SFML/System/Time.h>`

Go to the source code of this file.

## Functions

sfSocketSelector * | sfSocketSelector_create (void)
| Create a new selector.
sfSocketSelector * | sfSocketSelector_copy (const sfSocketSelector *selector)
| Create a new socket selector by copying an existing one.
void | sfSocketSelector_destroy (sfSocketSelector *selector)
| Destroy a socket selector.
void | sfSocketSelector_addTcpListener (sfSocketSelector *selector, sfTcpListener *socket)
| Add a new socket to a socket selector.
void | sfSocketSelector_addTcpSocket (sfSocketSelector *selector, sfTcpSocket *socket)
void | sfSocketSelector_addUdpSocket (sfSocketSelector *selector, sfUdpSocket *socket)
void | sfSocketSelector_removeTcpListener (sfSocketSelector *selector, sfTcpListener *socket)
| Remove a socket from a socket selector.
void | sfSocketSelector_removeTcpSocket (sfSocketSelector *selector, sfTcpSocket *socket)
void | sfSocketSelector_removeUdpSocket (sfSocketSelector *selector, sfUdpSocket *socket)
void | sfSocketSelector_clear (sfSocketSelector *selector)
| Remove all the sockets stored in a selector.
sfBool | sfSocketSelector_wait (sfSocketSelector *selector, sfTime timeout)
| Wait until one or more sockets are ready to receive.
sfBool | sfSocketSelector_isTcpListenerReady (const sfSocketSelector *selector, sfTcpListener *socket)
| Test a socket to know if it is ready to receive data.
sfBool | sfSocketSelector_isTcpSocketReady (const sfSocketSelector *selector, sfTcpSocket *socket)
sfBool | sfSocketSelector_isUdpSocketReady (const sfSocketSelector *selector, sfUdpSocket *socket)

## Function Documentation

## ◆ sfSocketSelector_addTcpListener()

void sfSocketSelector_addTcpListener | ( | sfSocketSelector * | selector,
|  | sfTcpListener * | socket
| ) |  |

Add a new socket to a socket selector.

This function keeps a weak pointer to the socket, so you have to make sure that the socket is not destroyed while it is stored in the selector.

Parameters

  selector | Socket selector object
  socket | Pointer to the socket to add

## ◆ sfSocketSelector_addTcpSocket()

void sfSocketSelector_addTcpSocket | ( | sfSocketSelector * | selector,
|  | sfTcpSocket * | socket
| ) |  |

## ◆ sfSocketSelector_addUdpSocket()

void sfSocketSelector_addUdpSocket | ( | sfSocketSelector * | selector,
|  | sfUdpSocket * | socket
| ) |  |

## ◆ sfSocketSelector_clear()

void sfSocketSelector_clear | ( | sfSocketSelector * | selector | ) |

Remove all the sockets stored in a selector.

This function doesn't destroy any instance, it simply removes all the pointers that the selector has to external sockets.

Parameters

  selector | Socket selector object

## ◆ sfSocketSelector_copy()

sfSocketSelector * sfSocketSelector_copy | ( | const sfSocketSelector * | selector | ) |

Create a new socket selector by copying an existing one.

Parameters

  selector | Socket selector to copy

Returns
  A new sfSocketSelector object which is a copy of selector

## ◆ sfSocketSelector_create()

sfSocketSelector * sfSocketSelector_create | ( | void |  | ) |

Create a new selector.

Returns
  A new sfSocketSelector object

## ◆ sfSocketSelector_destroy()

void sfSocketSelector_destroy | ( | sfSocketSelector * | selector | ) |

Destroy a socket selector.

Parameters

  selector | Socket selector to destroy

## ◆ sfSocketSelector_isTcpListenerReady()

sfBool sfSocketSelector_isTcpListenerReady | ( | const sfSocketSelector * | selector,
|  | sfTcpListener * | socket
| ) |  |

Test a socket to know if it is ready to receive data.

This function must be used after a call to sfSocketSelector_wait, to know which sockets are ready to receive data. If a socket is ready, a call to Receive will never block because we know that there is data available to read. Note that if this function returns sfTrue for a sfTcpListener, this means that it is ready to accept a new connection.

Parameters

  selector | Socket selector object
  socket | Socket to test

Returns
  sfTrue if the socket is ready to read, sfFalse otherwise

## ◆ sfSocketSelector_isTcpSocketReady()

sfBool sfSocketSelector_isTcpSocketReady | ( | const sfSocketSelector * | selector,
|  | sfTcpSocket * | socket
| ) |  |

## ◆ sfSocketSelector_isUdpSocketReady()

sfBool sfSocketSelector_isUdpSocketReady | ( | const sfSocketSelector * | selector,
|  | sfUdpSocket * | socket
| ) |  |

## ◆ sfSocketSelector_removeTcpListener()

void sfSocketSelector_removeTcpListener | ( | sfSocketSelector * | selector,
|  | sfTcpListener * | socket
| ) |  |

Remove a socket from a socket selector.

This function doesn't destroy the socket, it simply removes the pointer that the selector has to it.

Parameters

  selector | Socket selector object
  socket | POointer to the socket to remove

## ◆ sfSocketSelector_removeTcpSocket()

void sfSocketSelector_removeTcpSocket | ( | sfSocketSelector * | selector,
|  | sfTcpSocket * | socket
| ) |  |

## ◆ sfSocketSelector_removeUdpSocket()

void sfSocketSelector_removeUdpSocket | ( | sfSocketSelector * | selector,
|  | sfUdpSocket * | socket
| ) |  |

## ◆ sfSocketSelector_wait()

sfBool sfSocketSelector_wait | ( | sfSocketSelector * | selector,
|  | sfTime | timeout
| ) |  |

Wait until one or more sockets are ready to receive.

This function returns as soon as at least one socket has some data available to be received. To know which sockets are ready, use the sfSocketSelector_isXxxReady functions. If you use a timeout and no socket is ready before the timeout is over, the function returns sfFalse.

Parameters

  selector | Socket selector object
  timeout | Maximum time to wait (use sfTimeZero for infinity)

Returns
  sfTrue if there are sockets ready, sfFalse otherwise