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

Socket Class Reference

#include <Socket.h>

Inheritance diagram for Socket:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Socket ()
 Constructor of the socket.
virtual ~Socket ()
 Destructor of the socket.
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

Private Attributes

int m_sock
sockaddr_in m_addr

Constructor & Destructor Documentation

Socket::Socket  ) 
 

Constructor of the socket.

Definition at line 25 of file Socket.cpp.

References m_addr.

Socket::~Socket  )  [virtual]
 

Destructor of the socket.

Definition at line 35 of file Socket.cpp.

References is_valid().


Member Function Documentation

bool Socket::accept Socket new_socket  )  const
 

Accept socket.

Parameters:
new_socket 

Definition at line 116 of file Socket.cpp.

References m_sock.

Referenced by ServerSocket::accept().

bool Socket::bind const int  port  ) 
 

Bind socket.

Parameters:
port is the port to communicate with.

Definition at line 68 of file Socket.cpp.

References is_valid(), and m_addr.

Referenced by ServerSocket::ServerSocket().

bool Socket::connect const std::string  host,
const int  port
 

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 is_valid(), and m_addr.

Referenced by ClientSocket::Connect().

bool Socket::create  ) 
 

Create socket.

Definition at line 46 of file Socket.cpp.

References is_valid(), and m_sock.

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

bool Socket::is_valid  )  const [inline]
 

Definition at line 65 of file Socket.h.

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

bool Socket::listen  )  const
 

Listen to socket.

Definition at line 94 of file Socket.cpp.

References is_valid().

Referenced by ServerSocket::ServerSocket().

int Socket::recv std::string &  str  )  const
 

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 ClientSocket::operator>>().

bool Socket::send const std::string  str  )  const
 

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 ClientSocket::operator<<().

void Socket::set_non_blocking const   bool  ) 
 

Set non blocking.

Parameters:
b 

Definition at line 218 of file Socket.cpp.

References m_sock.


Member Data Documentation

sockaddr_in Socket::m_addr [private]
 

Definition at line 69 of file Socket.h.

Referenced by bind(), connect(), and Socket().

int Socket::m_sock [private]
 

Definition at line 68 of file Socket.h.

Referenced by accept(), create(), and set_non_blocking().


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