psocksxx 1.1.1
Loading...
Searching...
No Matches
Public Member Functions | List of all members
psocksxx::nsockstream Class Reference

Network (IPv4) controller class. More...

#include <nsockstream.h>

Inheritance diagram for psocksxx::nsockstream:
psocksxx::iosockstream psocksxx::isockstream psocksxx::osockstream psocksxx::iosocks psocksxx::iosocks psocksxx::tcpnsockstream psocksxx::udpnsockstream

Public Member Functions

 nsockstream (sockstreambuf::socket_type_t type, sockstreambuf::socket_protocol_t proto) throw ( sockexception )
 constructor
 
 nsockstream (sockstreambuf *ssb) throw ()
 constructor
 
virtual ~nsockstream () throw ()
 destructor
 
void connect (const nsockaddr *saddr) throw ( sockexception, socktimeoutexception )
 connect to a network address
 
void connect (const char *node, unsigned int port) throw ( sockexception, socktimeoutexception )
 connect to a network address
 
void bind (const nsockaddr *saddr, bool reuse_addr=false) throw ( sockexception )
 bind the stream to a network address
 
void listen (int backlog=0) throw ( sockexception )
 make this stream passive and ready to accept connections
 
nsockstreamaccept () throw ( sockexception )
 accept a connection on a listening (passive) stream
 
- Public Member Functions inherited from psocksxx::iosockstream
 iosockstream (sockstreambuf *ssb) throw ()
 constructor
 
virtual ~iosockstream () throw ()
 destructor
 
bool timedout () const throw ()
 get the timed-out status for this stream
 
- Public Member Functions inherited from psocksxx::isockstream
 isockstream (sockstreambuf *ssb) throw ()
 constructor
 
virtual ~isockstream () throw ()
 destructor
 
- Public Member Functions inherited from psocksxx::iosocks
virtual ~iosocks () throw ()
 destructor
 
bool timedout () const throw ()
 get the timed-out status flag value
 
const timeval * timeout (time_t sec, suseconds_t usec) throw ()
 set the timeout value for stream communications
 
void * clear_timeout () throw ()
 clear the timeout value
 
- Public Member Functions inherited from psocksxx::osockstream
 osockstream (sockstreambuf *ssb) throw ()
 constructor
 
virtual ~osockstream () throw ()
 destructor
 

Additional Inherited Members

- Protected Member Functions inherited from psocksxx::iosocks
 iosocks () throw ()
 empty default constructor
 

Detailed Description

Network (IPv4) controller class.

This is the base class for network (IP version 4) communications streams.

Constructor & Destructor Documentation

◆ nsockstream() [1/2]

psocksxx::nsockstream::nsockstream ( sockstreambuf::socket_type_t  type,
sockstreambuf::socket_protocol_t  proto 
)
throw (sockexception
)

constructor

Parameters
typesocket communications type
protosocket communications protocol
Exceptions
psocksxx::sockexceptionsocket exception

Open a network (IPv4) communications stream with the passed in type and protocol.

◆ nsockstream() [2/2]

psocksxx::nsockstream::nsockstream ( sockstreambuf ssb)
throw (
)

constructor

Parameters
ssbinitialised socket stream buffer instance

Initialise a network socket stream by using the passed in socket stream buffer, ssb, as the associated sequence which is assumed to be initialised with the correct type and protocol. The class destructor will delete the psocksxx::sockstreambuf instance pointed by ssb.

Member Function Documentation

◆ accept()

nsockstream * psocksxx::nsockstream::accept ( )
throw (sockexception
)

accept a connection on a listening (passive) stream

Exceptions
psocksxx::sockexceptionsocket exception
Returns
a new stream instance for the accepted connection

This method will accept an incoming connection on a listening stream and return a newly created stream instance that can be used to communicate with the accepted client connection. Note that the returned stream instance must be deleted by the caller.

◆ bind()

void psocksxx::nsockstream::bind ( const nsockaddr saddr,
bool  reuse_addr = false 
)
throw (sockexception
)

bind the stream to a network address

Parameters
saddraddress information to bind to
reuse_addrallow address to be re-used
Exceptions
psocksxx::sockexceptionsocket exception

This binds the network socket stream to the specified network address. If you want to try to bind to any socket that is not actively listening (e.g. TIME_WAIT) then set the reuse_addr parameter to be true.

◆ connect() [1/2]

void psocksxx::nsockstream::connect ( const char *  node,
unsigned int  port 
)
throw ( sockexception,
socktimeoutexception
)

connect to a network address

Parameters
nodenode (host name or IP)
portport number
Exceptions
psocksxx::sockexceptionsocket exception
psocksxx::socktimeoutexceptionconnection timeout exception

Connect to a IPv4 communication end point making this stream ready for I/O.

◆ connect() [2/2]

void psocksxx::nsockstream::connect ( const nsockaddr saddr)
throw ( sockexception,
socktimeoutexception
)

connect to a network address

Parameters
saddrdestination address information
Exceptions
psocksxx::sockexceptionsocket exception
psocksxx::socktimeoutexceptionconnection timeout exception

Connect to a IPv4 communication end point making this stream ready for I/O.

◆ listen()

void psocksxx::nsockstream::listen ( int  backlog = 0)
throw (sockexception
)

make this stream passive and ready to accept connections

Parameters
backlogmaximum length of the queue for pending connections and if this value is 0 (default) then it assumes system default
Exceptions
psocksxx::sockexceptionsocket exception

Make this network stream passive and ready to accept connections. Before calling this method the stream must be bound to a network address using the bind() method.