Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

Socket Class Reference

#include <cxxtools/net/net.h>

List of all members.

Public Member Functions

 Socket (int domain, int type, int protocol)
 A socket is created. On error a net::Exception is thrown.
 Socket (int fd=-1)
virtual ~Socket ()
bool good () const
 Returns true, if a socket is held.
bool bad () const
 Returns true, if no socket is held.
 operator bool () const
 Returns true, if a socket is held.
void create (int domain, int type, int protocol)
void close ()
 Closes the socket, if a socket is held.
int getFd () const
 Returns the socket handle.
std::string getSockAddr () const
 wrapper around getsockname(2)
void setTimeout (int t)
 Set timeout in milliseconds.
int getTimeout () const
 Returns timeout in milliseconds.
short poll (short events) const

Protected Member Functions

void setFd (int sockFd)


Detailed Description

Wrapper for BSD sockets.


Constructor & Destructor Documentation

Socket ( int  fd = -1  )  [explicit]

A socket is initialized with a existing socket descriptor. Ownership is transfered to this class.

virtual ~Socket (  )  [virtual]

The socket is released. Errors are printed on stderr.


Member Function Documentation

void create ( int  domain,
int  type,
int  protocol 
)

Creates a new socket. If a socket is already associated with this class, it is closed.

short poll ( short  events  )  const

execute poll(2) - throws Timeout-exception, when no data available after timeout

Copyright © 2008 The Tntnet Development Team
Tntnet 1.6