# PSocksSocket Class Reference

This is an ancestor class allowing access to a SOCKS servers (version 4 and 5). More...

`#include <socks.h>`

Inheritance diagram for PSocksSocket:

List of all members.

## Public Member Functions

| PSocksSocket (WORD port=0)
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.
PBoolean | Accept ()
| Open a socket to a remote host on the specified port number.
virtual PBoolean | Accept (PSocket &socket)
| Open a socket to 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)

## Protected Member Functions

virtual void | SetErrorCodes (PChannel::Errors errCode, int osErr)
int | TransferHandle (PSocksSocket &destination)

## Detailed Description

This is an ancestor class allowing access to a SOCKS servers (version 4 and 5).

## Constructor & Destructor Documentation

PSocksSocket::PSocksSocket | ( | WORD | port = `0` | ) |

## Member Function Documentation

virtual PBoolean PSocksSocket::Accept | ( | PSocket & | socket | ) | `[virtual]`

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

This is an "accepting" socket. When a "listening" socket has a pending connection to make, this will accept a connection made by the "connecting" socket created to establish a link.

The port that the socket uses is the one used in the `Listen()` command of the `socket` parameter.

Note that this function will block until a remote system connects to the port number specified in the "listening" socket.

Returns:
  true if the channel was successfully opened.

Parameters:

  socket | Listening socket making the connection.

Reimplemented from PTCPSocket.

PBoolean PSocksSocket::Accept | ( |  | ) |

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

This is an "accepting" socket. When a "listening" socket has a pending connection to make, this will accept a connection made by the "connecting" socket created to establish a link.

The port that the socket uses is the one used in the Listen() command of the `socket` parameter.

Note that this function will block until a remote system connects to the port number specified in the "listening" socket.

A further note is that when the version that uses a parameter is used, the `socket` parameter is automatically closed and its operating system handle transferred to the current object. This occurs regardless of the return value of the function.

Returns:
  true if the channel was successfully opened.

virtual PBoolean PSocksSocket::Connect | ( | const Address & | addr | ) | `[virtual]`

Parameters:

  addr | Address of remote machine to connect to.

virtual PBoolean PSocksSocket::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.

Parameters:

  address | Address of remote machine to connect to.

Reimplemented from PIPSocket.

virtual PBoolean PSocksSocket::GetLocalAddress | ( | Address & | addr,
|  | WORD & | port |
| ) |  |  | `[virtual]`

Parameters:

  addr | Variable to receive peer hosts IP address
  port | Variable to receive peer hosts port number

virtual PBoolean PSocksSocket::GetLocalAddress | ( | Address & | addr | ) | `[virtual]`

Get the Internet Protocol address for the local host.

Returns:
  true if the IP number was returned.

Parameters:

  addr | Variable to receive hosts IP address

virtual PBoolean PSocksSocket::GetPeerAddress | ( | Address & | addr,
|  | WORD & | port |
| ) |  |  | `[virtual]`

Parameters:

  addr | Variable to receive peer hosts IP address
  port | Variable to receive peer hosts port number

virtual PBoolean PSocksSocket::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.

Parameters:

  addr | Variable to receive hosts IP address

virtual PBoolean PSocksSocket::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.

Parameters:

  queueSize | Number of pending accepts that may be queued.
  port | Port number to use for the connection.
  reuse | Can/Cant listen more than once.

Reimplemented from PTCPSocket.

virtual void PSocksSocket::SetErrorCodes | ( | PChannel::Errors | errCode,
|  | int | osErr |
| ) |  |  | `[protected, virtual]`

Implements PSocksProtocol.

int PSocksSocket::TransferHandle | ( | PSocksSocket & | destination | ) | `[protected]`

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

- socks.h