Guit Socket; can either be a Server or a Client depending on it is started. More...
Public Types | |
enum | Mode |
Server Mode. | |
enum | Status |
Socket Status. More... | |
Public Member Functions | |
Mode | mode () const |
Returns socket mode (ie server or client, see enum Mode). | |
GInt & | status () |
Returns connexion status (see enum Status). | |
bool | startAsServer (int port) |
Starts the GSocket as a Server socket. More... | |
bool | startAsClient (GString const &hostname, int port) |
Starts the GSocket as a Client socket. More... | |
void | disconnect () |
Disconnects the socket. | |
GSocketChannel & | operator[] (GString const &name) |
Returns a channel of communication that can be bound to a mutable Property. More... | |
void | setSendBack (bool state) |
Specifies whether data is sent back while receiving data. More... | |
virtual void | error (GString const &funname, GString const &message) const |
Prints an error message. More... | |
void | operator delete (void *) |
delete does nothing, see GObject class. | |
void | forgetSmartPointers () |
Forgets all smart pointers pointing this object. More... | |
unsigned int | useCount () const |
Returns the numbers of smart pointers referencing the object. | |
virtual void | removeNotifiers (void *obj) |
[Implementation] Notifies this object that it must no longer refer obj. | |
template<class Subclass > | |
Subclass * | to () |
Class conversions. | |
void | ignoreSmartPointers () |
Checks/sets whether this object can be auto-deleted by smart pointers. More... | |
Protected Attributes | |
int | maxattempts_ {50} |
the socket is disconnected if it receives nothing more than this amount of times. | |
Guit Socket; can either be a Server or a Client depending on it is started.
After creating the GSocket, startAsServer() starts it as a server and startAsClient() as a client. A GSocket can manage an abritary set of GSocketChannel(s). Each of them is treated as a separate communication channel, and can be bound with a mutable Property (GVarProp).
Socket Status.
bool guit::GSocket::startAsServer | ( | int | port) |
bool guit::GSocket::startAsClient | ( | GString const & | hostname, |
int | port | ||
) |
GSocketChannel & guit::GSocket::operator[] | ( | GString const & | name) |
Returns a channel of communication that can be bound to a mutable Property.
mysocket["chan"] returns the channel named "chan". Data sent to this channel will be received by the channel with the same name on the other side, and vice-versa. The name must be an ASCII string without spaces nor special characters.
mysocket["*"] is a special channel that sends/receives all data unformatted. Other channels prefix data by "_name_:"
Callbacks can be added to each channel, and channels can be bound with mutable properties; see GSocketChannel for details.
|
inline |
Specifies whether data is sent back while receiving data.
Useful for avoiding useless data exchanges, especially when props are synced on both sides. When props are synced (or if both sides have callbacks) changing a updates b that updates a. If a has not been changed in the meantime everything is fine, otherwise this may cause jitter or infinite loops.
|
virtualinherited |
Prints an error message.
|
inlineinherited |
Checks/sets whether this object can be auto-deleted by smart pointers.
ignoreSmartPointers() has a permanent effect, contrary to forgetSmartPointers(). Objects not created by calling new are never auto-deleted by smart pointers.
|
inlineinherited |
Forgets all smart pointers pointing this object.
The smart pointers that are currently pointing to the object won't auto-delete it. forgetSmartPointers() has a temporary effect, contrary to ignoreSmartPointers().