#include <communSocket.h>
Inheritance diagram for CommunSocket::
Public Methods | |
CommunSocket (int connectMode, const String &hostname, unsigned short port) | |
Constructor. More... | |
virtual | ~CommunSocket () |
Destructor. More... | |
virtual int | initialize () |
Initialization of communication. More... | |
virtual Commun & | operator>> (Buffer &b) |
Read data. More... | |
virtual Commun & | operator<< (const Buffer &b) |
Write data. More... | |
virtual int | isReady () |
Communication channel ready for reading. More... | |
Private Attributes | |
int | _sock |
socket la unix (server). | |
int | _csock |
socket la unix (client). | |
fd_set | _fds |
temporary FDSET for select() call. | |
String | _hostname |
Hostname. More... | |
unsigned short | _port |
Port number. More... | |
int | _connectMode |
connect mode (0 = server, 1 = client). |
This class implements TCP/IP socket communication and offers the user of this class the standard interface of Commun class. Implementation is system dependent (so it is different on WIN32 and UNIX systems). This class stands a server or client out.
Definition at line 53 of file communSocket.h.
|
Constructor. It initializes server for listening on given port (if connectMode is set to 'server'). If connectMode is set to 'client', this class connects to the target specified by hostname and port arguments.
Definition at line 37 of file communSocket.cpp. |
|
Destructor. It stops communication and closes communication channel. Definition at line 78 of file communSocket.cpp. |
|
Initialization of communication. This method initializes socket communication - waits for client and makes a connection. Once a client is connected to this server, another client has no possibility to connect. If used in client mode, it tries to connect to server.
Reimplemented from Commun. Definition at line 103 of file communSocket.cpp. |
|
Communication channel ready for reading. This method returns TRUE, if there are data in communication channel and should be read from it.
Reimplemented from Commun. Definition at line 226 of file communSocket.cpp. |
|
Write data. This operator is used to write data from buffer to communication channel (socket).
Reimplemented from Commun. Definition at line 172 of file communSocket.cpp. |
|
Read data. This operator is used to read data from communication channel (socket) to buffer.
Reimplemented from Commun. Definition at line 191 of file communSocket.cpp. |
|
Hostname. It is used only when connectMode is set to 'client' (1); it contains target host's name. Definition at line 75 of file communSocket.h. |
|
Port number. When connectMode is set to 'server' (0), it contains port number, where server listens for new connections; when connectMode is set to 'client' (1), it contains target host's port number. Definition at line 82 of file communSocket.h. |