Represents a listening Server, ready to accept incoming images. More...
#include <Server.h>
Public Member Functions | |
Server () | |
Constructor. | |
Server (int port) | |
Constructor. | |
~Server () | |
Destructor. | |
void | connect (int port, bool seach=false) |
Connects the server to a port. | |
void | accept () |
Sets up the server to accept an incoming Client connections. | |
Data | listen () |
Listens for incoming messages from a Client. | |
void | quit () |
Sends a 'quit' message to the server. | |
bool | isConnected () |
Returns whether or not the server is connected to a port. | |
int | getPort () |
Returns the port the server is currently connected to. |
Represents a listening Server, ready to accept incoming images.
This class wraps up the provision of a TCP port, and handles incoming connections from Client objects when they're ready to send image data.
Server::Server | ( | ) |
Constructor.
Creates a new server. By default the Server is not connected at creation time.
Server::Server | ( | int | port | ) |
Constructor.
Creates a new server and calls connect() with the specified port number.
Server::~Server | ( | ) |
Destructor.
Shuts down the server, closing any open ports if the server is connected.
void Server::connect | ( | int | port, | |
bool | seach = false | |||
) |
Connects the server to a port.
If true is passed as the second parameter then the server will search for the first available port if the specified one is not available. To find out which port the server managed to connect to, call getPort() afterwards.
Data Server::listen | ( | ) |
void Server::quit | ( | ) |
Sends a 'quit' message to the server.
This can be used to exit a listening loop running on a separate thread.