classPiiNetworkClient
#include <PiiNetworkClient.h>
A generic client for network connections.
Inherits QObject
Description
PiiNetworkClient tries to keep a connection open to avoid unnecessary reconnection delays.
Public Slots
|
void
|
( )
Closes the connection to the server. |
Constructors and destructor
|
Creates a new network client that is used to communicate with the server at the given address. |
|
|
Destroys the device. |
Public member functions
|
int
|
Returns the connection time-out. |
|
( )
Opens a connection to the server. |
|
|
( )
Returns the current server address. |
|
|
void
|
(
Sets the maximum number of milliseconds the PiiNetworkClient will wait for a successful connection. |
|
void
|
Sets the server address. |
Function details
-
PiiNetworkClient
Creates a new network client that is used to communicate with the server at the given address.
See PiiHttpServer for valid address formats. Note that there must be no slash at the end of the address.
-
~PiiNetworkClient
()Destroys the device.
-
int connectionTimeout
()Returns the connection time-out.
-
PiiSocketDevice openConnection
()Opens a connection to the server.
The connection will be kept alive if possible. Subsequent calls to this function check if the connection is still open and try to reopen it if possible.
Returns
a pointer to the communication device, or zero if the connection failed. The QIODevice pointer in the returned device is owned by PiiNetworkClient and must not be deleted by the caller.
-
QString serverAddress
()Returns the current server address.
-
void setConnectionTimeout
(- int connectionTimeout
Sets the maximum number of milliseconds the PiiNetworkClient will wait for a successful connection.
Set this value before calling openConnection(). The default value is 5000.
-
void setServerAddress
Sets the server address.
The server at the new address will be first contacted when openConnection() is called next time. See PiiHttpServer for valid address formats. If the server address changes, the next openConnection() call will delete the current communication device and create a new one.
client.setServerAddress("tcp://127.0.0.1:3142");
-
void closeConnection
()[slot]Closes the connection to the server.
Add a note
Not a single note added yet. Be the first, add yours.