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

Socket Class Reference

#include <cxxtools/net.h>

Inheritance diagram for Socket:

Server Stream iostream List of all members.

Public Member Functions

 Socket (int domain, int type, int protocol) throw (Exception)
 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
 operator bool () const
 Returns true, if a socket is held.
void create (int domain, int type, int protocol) throw (Exception)
void close ()
 Closes the socket, if a socket is held.
int getFd () const
 Returns the socket handle.
sockaddr_storage getSockAddr () const throw (Exception)
 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

bool bad (  )  const

Liefert true zurück, wenn der Socket nicht geöffnet ist Returns true, if no socket is held.

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

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