Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

ClientSocket Class Reference

#include <ClientSocket.h>

Inheritance diagram for ClientSocket:

Inheritance graph
[legend]
Collaboration diagram for ClientSocket:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ClientSocket ()
 Client Socket constructor.
 ClientSocket (std::string host, int port)
 Create client socket and connect to server.
virtual ~ClientSocket ()
 Client Socket constructor.
void Connect (std::string host, int port)
 Create client socket and connect to server.
const ClientSocketoperator<< (const std::string &) const
 Send string to server.
const ClientSocketoperator>> (std::string &) const
 Receiver string from server.

Private Member Functions

bool create ()
 Create socket.
bool bind (const int port)
 Bind socket.
bool listen () const
 Listen to socket.
bool accept (Socket &) const
 Accept socket.
bool connect (const std::string host, const int port)
 Connect to the host.
bool send (const std::string) const
 Send string to socket.
int recv (std::string &) const
 Receive string from socket.
void set_non_blocking (const bool)
 Set non blocking.
bool is_valid () const

Constructor & Destructor Documentation

ClientSocket::ClientSocket  ) 
 

Client Socket constructor.

Definition at line 25 of file ClientSocket.cpp.

ClientSocket::ClientSocket std::string  host,
int  port
 

Create client socket and connect to server.

Parameters:
host is the IP address (xxx.xxx.xxx.xxx) or host name (vt.edu) of the server
port is the open port on the server
Returns:
throw SocketException if error

Definition at line 35 of file ClientSocket.cpp.

References Connect().

ClientSocket::~ClientSocket  )  [virtual]
 

Client Socket constructor.

Definition at line 44 of file ClientSocket.cpp.


Member Function Documentation

bool Socket::accept Socket new_socket  )  const [inherited]
 

Accept socket.

Parameters:
new_socket 

Definition at line 116 of file Socket.cpp.

References Socket::m_sock.

Referenced by ServerSocket::accept().

bool Socket::bind const int  port  )  [inherited]
 

Bind socket.

Parameters:
port is the port to communicate with.

Definition at line 68 of file Socket.cpp.

References Socket::is_valid(), and Socket::m_addr.

Referenced by ServerSocket::ServerSocket().

bool Socket::connect const std::string  host,
const int  port
[inherited]
 

Connect to the host.

Parameters:
host is the IP address (xxx.xxx.xxx.xxx) or host name (vt.edu)
port is the port number for the host

Definition at line 187 of file Socket.cpp.

References Socket::is_valid(), and Socket::m_addr.

Referenced by Connect().

void ClientSocket::Connect std::string  host,
int  port
 

Create client socket and connect to server.

Parameters:
host is the IP address (xxx.xxx.xxx.xxx) or host name (vt.edu) of the server
port is the open port on the server
Returns:
throw SocketException if error

Definition at line 54 of file ClientSocket.cpp.

References Socket::connect(), and Socket::create().

Referenced by ClientSocket().

bool Socket::create  )  [inherited]
 

Create socket.

Definition at line 46 of file Socket.cpp.

References Socket::is_valid(), and Socket::m_sock.

Referenced by Connect(), and ServerSocket::ServerSocket().

bool Socket::is_valid  )  const [inline, inherited]
 

Definition at line 65 of file Socket.h.

Referenced by Socket::bind(), Socket::connect(), Socket::create(), Socket::listen(), and Socket::~Socket().

bool Socket::listen  )  const [inherited]
 

Listen to socket.

Definition at line 94 of file Socket.cpp.

References Socket::is_valid().

Referenced by ServerSocket::ServerSocket().

const ClientSocket & ClientSocket::operator<< const std::string &  str  )  const
 

Send string to server.

Parameters:
str sting of data to send
Returns:
throw SocketException if error

Definition at line 73 of file ClientSocket.cpp.

References Socket::send().

const ClientSocket & ClientSocket::operator>> std::string &  str  )  const
 

Receiver string from server.

Parameters:
str sting of data to send
Returns:
throw SocketException if error

Definition at line 90 of file ClientSocket.cpp.

References Socket::recv().

int Socket::recv std::string &  str  )  const [inherited]
 

Receive string from socket.

Parameters:
str is the string of data to be received
Returns:
status

Definition at line 155 of file Socket.cpp.

References MAXRECV.

Referenced by ServerSocket::operator>>(), and operator>>().

bool Socket::send const std::string  str  )  const [inherited]
 

Send string to socket.

Parameters:
str is the string of data to be sent

Definition at line 136 of file Socket.cpp.

Referenced by ServerSocket::operator<<(), and operator<<().

void Socket::set_non_blocking const   bool  )  [inherited]
 

Set non blocking.

Parameters:
b 

Definition at line 218 of file Socket.cpp.

References Socket::m_sock.


The documentation for this class was generated from the following files:
Generated on Wed Sep 5 12:54:38 2007 for DSACSS Operational Code by  doxygen 1.3.9.1