PTLib  Version 2.10.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PSocksUDPSocket Class Reference

This class allows access to RFC1928 compliant SOCKS server. More...

#include <socks.h>

Inheritance diagram for PSocksUDPSocket:
PUDPSocket PSocksProtocol PIPDatagramSocket PIPSocket PSocket PChannel PObject

Public Member Functions

 PSocksUDPSocket (WORD port=0)
 PSocksUDPSocket (const PString &host, WORD port=0)
virtual PObjectClone () const
 Create a copy of the class on the heap.
virtual PBoolean Connect (const PString &address)
 Connect a socket to a remote host on the specified port number.
virtual PBoolean Connect (const Address &addr)
virtual PBoolean Listen (unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive)
 Listen on a socket for a remote host on the specified port number.
virtual PBoolean GetLocalAddress (Address &addr)
 Get the Internet Protocol address for the local host.
virtual PBoolean GetLocalAddress (Address &addr, WORD &port)
virtual PBoolean GetPeerAddress (Address &addr)
 Get the Internet Protocol address for the peer host the socket is connected to.
virtual PBoolean GetPeerAddress (Address &addr, WORD &port)
virtual PBoolean ReadFrom (void *buf, PINDEX len, Address &addr, WORD &port)
 Read a datagram from a remote computer.
virtual PBoolean WriteTo (const void *buf, PINDEX len, const Address &addr, WORD port)
 Write a datagram to a remote computer.
- Public Member Functions inherited from PUDPSocket
 PUDPSocket (WORD port=0, int iAddressFamily=AF_INET)
 Create a UDP socket.
 PUDPSocket (PQoS *qos, WORD port=0, int iAddressFamily=AF_INET)
 PUDPSocket (const PString &service, PQoS *qos=NULL, int iAddressFamily=AF_INET)
 PUDPSocket (const PString &address, WORD port)
 PUDPSocket (const PString &address, const PString &service)
PBoolean Read (void *buf, PINDEX len)
 Override of PChannel functions to allow connectionless reads.
PBoolean Write (const void *buf, PINDEX len)
 Override of PChannel functions to allow connectionless writes.
void SetSendAddress (const Address &address, WORD port)
 Set the address to use for connectionless Write() or Windows QoS.
void GetSendAddress (Address &address, WORD &port) const
 Get the address to use for connectionless Write().
PString GetSendAddress () const
void GetLastReceiveAddress (Address &address, WORD &port) const
 Get the address of the sender in the last connectionless Read().
PString GetLastReceiveAddress () const
virtual PBoolean IsAlternateAddress (const Address &address, WORD port)
 CallBack to check if the detected address of the connectionless Read() is an alternate address.
virtual PBoolean DoPseudoRead (int &selectStatus)
 PseudoRead This indicates to the upper system that reading on this socket will be a pseudo read when means there is data available that did not orginate from the physical socket but was programmically injected.
virtual PBoolean ModifyQoSSpec (PQoS *qos)
 Change the QOS spec for the socket and try to apply the changes.
virtual PQoSGetQoSSpec ()
 Get the QOS object for the socket.
- Public Member Functions inherited from PSocksProtocol
 PSocksProtocol (WORD port)
virtual ~PSocksProtocol ()
PBoolean SetServer (const PString &hostname, const char *service="socks 1080")
PBoolean SetServer (const PString &hostname, WORD port)
void SetAuthentication (const PString &username, const PString &password)
 Set the username and password for the SOCKS server authentication.

Protected Member Functions

virtual void SetErrorCodes (PChannel::Errors errCode, int osErr)
- Protected Member Functions inherited from PUDPSocket
virtual PBoolean OpenSocket ()
virtual PBoolean OpenSocket (int ipAdressFamily)
 Open an IPv4 or IPv6 socket.
virtual PBoolean OpenSocketGQOS (int af, int type, int proto)
virtual PBoolean ApplyQoS ()
virtual const char * GetProtocolName () const
 This function returns the protocol name for the socket type.
- Protected Member Functions inherited from PIPDatagramSocket
 PIPDatagramSocket ()
 Create a TCP/IP protocol socket channel.
- Protected Member Functions inherited from PIPSocket
 PIPSocket ()
 Create a new Internet Protocol socket based on the port number specified.
- Protected Member Functions inherited from PSocket
 PSocket ()
int os_close ()
int os_socket (int af, int type, int proto)
PBoolean os_connect (struct sockaddr *sin, PINDEX size)
PBoolean os_recvfrom (void *buf, PINDEX len, int flags, struct sockaddr *from, PINDEX *fromlen)
PBoolean os_sendto (const void *buf, PINDEX len, int flags, struct sockaddr *to, PINDEX tolen)
PBoolean os_accept (PSocket &listener, struct sockaddr *addr, PINDEX *size)
- Protected Member Functions inherited from PChannel
 PChannel (const PChannel &)
PChanneloperator= (const PChannel &)
virtual PBoolean ConvertOSError (int libcReturnValue, ErrorGroup group=LastGeneralError)
 Convert an operating system error into platform independent error.
int ReadCharWithTimeout (PTimeInterval &timeout)
 Read a character with specified timeout.
PBoolean ReceiveCommandString (int nextChar, const PString &reply, PINDEX &pos, PINDEX start)
PBoolean PXSetIOBlock (PXBlockType type, const PTimeInterval &timeout)
int PXClose ()
- Protected Member Functions inherited from PObject
 PObject ()
 Constructor for PObject, made protected so cannot ever create one on its own.
- Protected Member Functions inherited from PSocksProtocol
PBoolean ConnectSocksServer (PTCPSocket &thisSocket)
virtual PBoolean SendSocksCommand (PTCPSocket &socket, BYTE command, const char *hostname, PIPSocket::Address addr)
virtual PBoolean ReceiveSocksResponse (PTCPSocket &socket, PIPSocket::Address &addr, WORD &port)

Protected Attributes

PTCPSocket socksControl
Address serverAddress
- Protected Attributes inherited from PUDPSocket
Address sendAddress
WORD sendPort
Address lastReceiveAddress
WORD lastReceivePort
PQoS qosSpec
- Protected Attributes inherited from PSocksProtocol
PString serverHost
WORD serverPort
PString authenticationUsername
PString authenticationPassword
PIPSocket::Address remoteAddress
WORD remotePort
PIPSocket::Address localAddress
WORD localPort

Additional Inherited Members

- Public Types inherited from PSocket
enum  Reusability { CanReuseAddress, AddressIsExclusive }
 Flags to reuse of port numbers in Listen() function. More...
- Public Types inherited from PChannel
enum  PXBlockType { PXReadBlock, PXWriteBlock, PXAcceptBlock, PXConnectBlock }
enum  ShutdownValue { ShutdownRead = 0, ShutdownWrite = 1, ShutdownReadAndWrite = 2 }
enum  Errors {
  NoError, NotFound, FileExists, DiskFull,
  AccessDenied, DeviceInUse, BadParameter, NoMemory,
  NotOpen, Timeout, Interrupted, BufferTooSmall,
  Miscellaneous, ProtocolFailure, NumNormalisedErrors
}
 Normalised error codes. More...
enum  ErrorGroup { LastReadError, LastWriteError, LastGeneralError, NumErrorGroups }
 Error groups. More...
typedef std::vector< SliceVectorOfSlice
- Public Types inherited from PSocksProtocol
enum  { DefaultServerPort = 1080 }
- Static Public Member Functions inherited from PUDPSocket
static PBoolean SupportQoS (const PIPSocket::Address &address)
 Check to See if the socket will support QoS on the given local Address.
static void EnableGQoS ()
 Manually Enable GQoS Support.
- Static Public Member Functions inherited from PIPSocket
static int GetDefaultIpAddressFamily ()
 Set the default IP address familly.
static void SetDefaultIpAddressFamily (int ipAdressFamily)
static void SetDefaultIpAddressFamilyV4 ()
static PIPSocket::Address GetDefaultIpAny ()
static void SetSuppressCanonicalName (bool suppress)
 Set flag for suppress getting canonical name when doing lookup via hostname.
static bool GetSuppressCanonicalName ()
 Get flag for suppress getting canonical name when doing lookup via hostname.
static PString GetHostName ()
 Get the "official" host name for the host specified or if none, the host this process is running on.
static PString GetHostName (const PString &hostname)
static PString GetHostName (const Address &addr)
static PBoolean GetHostAddress (Address &addr)
 Get the Internet Protocol address for the specified host, or if none specified, for the host this process is running on.
static PBoolean GetHostAddress (const PString &hostname, Address &addr)
static PStringArray GetHostAliases (const PString &hostname)
 Get the alias host names for the specified host.
static PStringArray GetHostAliases (const Address &addr)
static PBoolean IsLocalHost (const PString &hostname)
 Determine if the specified host is actually the local machine.
static void ClearNameCache ()
 Clear the name (DNS) cache.
static PBoolean GetGatewayAddress (Address &addr, int version=4)
 Get the IP address that is being used as the gateway, that is, the computer that packets on the default route will be sent.
static PString GetGatewayInterface (int version=4)
 Get the name for the interface that is being used as the gateway, that is, the interface that packets on the default route will be sent.
static PIPSocket::Address GetRouteInterfaceAddress (PIPSocket::Address remoteAddress)
 Get the interface address that will be used to reach the specified remote address.
static PBoolean GetRouteTable (RouteTable &table)
 Get the systems route table.
static RouteTableDetectorCreateRouteTableDetector ()
 Create an object that can wait for a change in the route table or active network interfaces.
static PBoolean GetInterfaceTable (InterfaceTable &table, PBoolean includeDown=false)
 Get a list of all interfaces.
static PBoolean GetNetworkInterface (PIPSocket::Address &addr)
 Get the address of an interface that corresponds to a real network.
- Static Public Member Functions inherited from PSocket
static int Select (PSocket &sock1, PSocket &sock2)
 Select a socket with available data.
static int Select (PSocket &sock1, PSocket &sock2, const PTimeInterval &timeout)
 Select a socket with available data.
static Errors Select (SelectList &read)
 Select a socket with available data.
static Errors Select (SelectList &read, const PTimeInterval &timeout)
 Select a socket with available data.
static Errors Select (SelectList &read, SelectList &write)
 Select a socket with available data.
static Errors Select (SelectList &read, SelectList &write, const PTimeInterval &timeout)
 Select a socket with available data.
static Errors Select (SelectList &read, SelectList &write, SelectList &except)
 Select a socket with available data.
static Errors Select (SelectList &read, SelectList &write, SelectList &except, const PTimeInterval &timeout)
 Select a socket with available data.
static WORD Host2Net (WORD v)
 Convert from host to network byte order.
static DWORD Host2Net (DWORD v)
 Convert from host to network byte order.
static WORD Net2Host (WORD v)
 Convert from network to host byte order.
static DWORD Net2Host (DWORD v)
 Convert from network to host byte order.
static WORD GetProtocolByName (const PString &name)
 Get the number of the protocol associated with the specified name.
static PString GetNameByProtocol (WORD proto)
 Get the name of the protocol number specified.
static WORD GetPortByService (const char *protocol, const PString &service)
 Get the port number for the specified service name.
static PString GetServiceByPort (const char *protocol, WORD port)
 Get the service name from the port number.
- Friends inherited from PObject

Detailed Description

This class allows access to RFC1928 compliant SOCKS server.

Constructor & Destructor Documentation

PSocksUDPSocket::PSocksUDPSocket ( WORD  port = 0)
PSocksUDPSocket::PSocksUDPSocket ( const PString host,
WORD  port = 0 
)

Member Function Documentation

virtual PObject* PSocksUDPSocket::Clone ( ) const
virtual

Create a copy of the class on the heap.

The exact semantics of the descendent class determine what is required to make a duplicate of the instance. Not all classes can even do a clone operation.

The main user of the clone function is the PDictionary class as it requires copies of the dictionary keys.

The default behaviour is for this function to assert.

Returns
pointer to new copy of the class instance.

Reimplemented from PObject.

virtual PBoolean PSocksUDPSocket::Connect ( const PString address)
virtual

Connect a socket to a remote host on the specified port number.

This is typically used by the client or initiator of a communications channel. This connects to a "listening" socket at the other end of the communications channel.

The port number as defined by the object instance construction or the PIPSocket::SetPort() function.

Returns
true if the channel was successfully connected to the remote host.

Reimplemented from PUDPSocket.

virtual PBoolean PSocksUDPSocket::Connect ( const Address addr)
virtual

Reimplemented from PIPSocket.

virtual PBoolean PSocksUDPSocket::GetLocalAddress ( Address addr)
virtual

Get the Internet Protocol address for the local host.

Returns
true if the IP number was returned.

Reimplemented from PIPSocket.

virtual PBoolean PSocksUDPSocket::GetLocalAddress ( Address addr,
WORD &  port 
)
virtual

Reimplemented from PIPSocket.

virtual PBoolean PSocksUDPSocket::GetPeerAddress ( Address addr)
virtual

Get the Internet Protocol address for the peer host the socket is connected to.

Returns
true if the IP number was returned.

Reimplemented from PIPSocket.

virtual PBoolean PSocksUDPSocket::GetPeerAddress ( Address addr,
WORD &  port 
)
virtual

Reimplemented from PIPSocket.

virtual PBoolean PSocksUDPSocket::Listen ( unsigned  queueSize = 5,
WORD  port = 0,
Reusability  reuse = AddressIsExclusive 
)
virtual

Listen on a socket for a remote host on the specified port number.

This may be used for server based applications. A "connecting" socket begins a connection by initiating a connection to this socket. An active socket of this type is then used to generate other "accepting" sockets which establish a two way communications channel with the "connecting" socket.

If the port parameter is zero then the port number as defined by the object instance construction or the PIPSocket::SetPort() function.

For the UDP protocol, the queueSize parameter is ignored.

Returns
true if the channel was successfully opened.

Reimplemented from PIPSocket.

virtual PBoolean PSocksUDPSocket::ReadFrom ( void *  buf,
PINDEX  len,
Address addr,
WORD &  port 
)
virtual

Read a datagram from a remote computer.

Returns
true if any bytes were sucessfully read.

Reimplemented from PIPDatagramSocket.

virtual void PSocksUDPSocket::SetErrorCodes ( PChannel::Errors  errCode,
int  osErr 
)
protectedvirtual

Implements PSocksProtocol.

virtual PBoolean PSocksUDPSocket::WriteTo ( const void *  buf,
PINDEX  len,
const Address addr,
WORD  port 
)
virtual

Write a datagram to a remote computer.

Returns
true if all the bytes were sucessfully written.

Reimplemented from PIPDatagramSocket.

Member Data Documentation

Address PSocksUDPSocket::serverAddress
protected
PTCPSocket PSocksUDPSocket::socksControl
protected

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