Dangerous SNMP
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
BasicSocketTransport Class Reference

This is the base class of both the UDP and TCP transports. More...

#include <basicsockettransport.hpp>

Inheritance diagram for BasicSocketTransport:
Transport Tcp Udp

Public Member Functions

 BasicSocketTransport (std::weak_ptr< Context::PrivateData > context)
 
virtual bool isConnected ()
 This returns whether or not the transport is connected. More...
 
virtual void connect ()
 This instructs the transport to connect to its endpoint. More...
 
virtual void disconnect ()
 This shuts down the transport (if it was already connected). More...
 
bool send (const std::vector< char > &bytes)
 
std::vector< char > receive (const std::chrono::milliseconds &timeout)
 
- Public Member Functions inherited from Transport
unsigned int maximumIncomingMessageSize ()
 
unsigned int maximumOutgoingMessageSize ()
 
void commitWrite ()
 

Protected Member Functions

virtual int socketOptions () const
 When creating a socket, this is called to set the options that should be passed to the call. More...
 
virtual int protocolNumber () const
 When creating a socket, this is called to set the protocol that should be passed to the call. More...
 
- Protected Member Functions inherited from Transport
 Transport (std::weak_ptr< Context::PrivateData > context)
 
void registerReadWriteStreams (int readHandle, int writeHandle)
 
void unregisterReadWriteStreams (int readHandle, int writeHandle)
 

Protected Attributes

int socketHandle
 This is the socket handle.
 
std::string address
 This is the address to which to connect. More...
 
std::string port
 This is the port on which to connect. More...
 
- Protected Attributes inherited from Transport
unsigned int _maximumIncomingMessageSize
 
unsigned int _maximumOutgoingMessageSize
 
std::weak_ptr
< Context::PrivateData
context
 

Additional Inherited Members

- Public Attributes inherited from Transport
std::shared_ptr< ByteStreamreaderStream
 
std::shared_ptr< ByteStreamwriterStream
 

Detailed Description

This is the base class of both the UDP and TCP transports.

Because the Berkeley socket API is implemented in such a way as to make any transports that use it almost identical, this class serves to handle all of major work, with the subclasses handling any specifics (such as the protocol number or "socket" options).

Member Function Documentation

virtual void connect ( )
virtual

This instructs the transport to connect to its endpoint.

This may or may not succeed; to check for success, call "isConnected" afterward.

Reimplemented from Transport.

virtual void disconnect ( )
virtual

This shuts down the transport (if it was already connected).

If the transport was not connected, then this does nothing.

Reimplemented from Transport.

virtual bool isConnected ( )
virtual

This returns whether or not the transport is connected.

Returns
true if it is connected; false if it is not.

Reimplemented from Transport.

virtual int protocolNumber ( ) const
protectedvirtual

When creating a socket, this is called to set the protocol that should be passed to the call.

It is the responsibility of the subclass to properly fill this out.

Returns
The relevant value for addrinfo.ai_protocol.

Reimplemented in Tcp, and Udp.

virtual int socketOptions ( ) const
protectedvirtual

When creating a socket, this is called to set the options that should be passed to the call.

It is the responsibility of the subclass to properly fill this out.

Returns
The relevant value for addrinfo.ai_socktype.

Reimplemented in Tcp, and Udp.

Member Data Documentation

std::string address
protected

This is the address to which to connect.

This may be any string, including an IPv4 address, IPv6 address, a DNS name, etc.

std::string port
protected

This is the port on which to connect.

This may be any string, including a port number as well as the named "service" (if the system can translate it).


The documentation for this class was generated from the following file: