Waits on a specified socket address for incoming connections.
More...
#include <rw/network/RWSocketListener.h>
Waits on a specified socket address for incoming connections. Connections are obtained as RWSocketPortal instances.
◆ RWSocketListener() [1/3]
RWSocketListener::RWSocketListener |
( |
| ) |
|
Creates an uninitialized socket listener. Self
needs to be initialized using listen() before it can be used.
◆ RWSocketListener() [2/3]
RWSocketListener::RWSocketListener |
( |
const RWSockAddrBase & | address, |
|
|
int | backlog = 5 ) |
|
explicit |
Sets up a listener on the address indicated, and sets up a queue to wait for connections. The backlog parameter specifies the number of incoming connection requests that the protocol software enqueues while a connection is being processed.
- Note
- This constructor initializes a socket and sets the
SO_REUSEADDR
option on the socket. If you do not want this option to be set, pass an initalized socket to RWSocketListener(const RWSocket&,WhoShouldClose). See section "Socket
Security" under Chapter 8, "The Windows Socket Adapter" in the Essential Networking Module User's Guide for more information.
◆ RWSocketListener() [3/3]
Creates a listening portal to the communications channel, where socket is the socket doing the listening. Using this constructor is the only way to create a socket that is not closed automatically when portals are no longer using it.
◆ ~RWSocketListener()
RWSocketListener::~RWSocketListener |
( |
| ) |
|
◆ accept()
Receives the next waiting connection. The address of the connecting client will be stored in the RWSockAddr referenced by addr.
◆ getSocket()
RWSocket RWSocketListener::getSocket |
( |
| ) |
const |
Obtains a reference to the underlying socket.
◆ listen()
void RWSocketListener::listen |
( |
const RWSockAddrBase & | address, |
|
|
int | backlog = 5 ) |
Binds the listener to the address indicated, and sets up a queue to wait for connections. The backlog parameter specifies the number of incoming connection requests that the protocol software enqueues while a connection is being processed.
- Note
- This function initializes a socket and sets the
SO_REUSEADDR
option on the socket. If you do not want this option to be set, pass an initalized socket to RWSocketListener(const RWSocket&,WhoShouldClose). See section "Socket
Security" under Chapter 8, "The Windows Socket Adapter" in the Essential Networking Module User's Guide for more information.
◆ operator()()
Receives the next waiting connection. The address of the connecting client will be stored in the RWSockAddr referenced by addr.