Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

CommunSocket Class Reference

Socket communication. More...

#include <communSocket.h>

Inheritance diagram for CommunSocket::

Commun List of all members.

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 Communoperator>> (Buffer &b)
 Read data. More...

virtual Communoperator<< (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).


Detailed Description

Socket communication.

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.

See also:
CommunShMem, Commun
Author:
Marek Przeczek

Definition at line 53 of file communSocket.h.


Constructor & Destructor Documentation

CommunSocket::CommunSocket int    connectMode,
const String   hostname,
unsigned short    port
 

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.

Parameters:
connectMode  mode (0 = as server, 1 = as client)
hostname  target host (if connectMode is set to 'client')
port  port number

Definition at line 37 of file communSocket.cpp.

CommunSocket::~CommunSocket   [virtual]
 

Destructor.

It stops communication and closes communication channel.

Definition at line 78 of file communSocket.cpp.


Member Function Documentation

int CommunSocket::initialize   [virtual]
 

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.

Returns:
0 (failed); 1 (ok, client connected)

Reimplemented from Commun.

Definition at line 103 of file communSocket.cpp.

int CommunSocket::isReady   [virtual]
 

Communication channel ready for reading.

This method returns TRUE, if there are data in communication channel and should be read from it.

Returns:
0 (nothing); 1 (data in channel)

Reimplemented from Commun.

Definition at line 226 of file communSocket.cpp.

Commun & CommunSocket::operator<< const Buffer   b [virtual]
 

Write data.

This operator is used to write data from buffer to communication channel (socket).

Parameters:
b  reference to Buffer object
Returns:
reference to this Commun object
See also:
operator>>()

Reimplemented from Commun.

Definition at line 172 of file communSocket.cpp.

Commun & CommunSocket::operator>> Buffer   b [virtual]
 

Read data.

This operator is used to read data from communication channel (socket) to buffer.

Parameters:
b  reference to Buffer object
Returns:
reference to this Commun object
See also:
operator<<()

Reimplemented from Commun.

Definition at line 191 of file communSocket.cpp.


Member Data Documentation

String CommunSocket::_hostname [private]
 

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.

unsigned short CommunSocket::_port [private]
 

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.


The documentation for this class was generated from the following files:
Generated on Mon Jan 28 14:53:28 2002 for Java Profiler Dynamic Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001