Skip to content

JDWX DNSQuery Network IPTransport

JDW edited this page Jul 17, 2022 · 1 revision

JDWX\DNSQuery\Network\IPTransport

Provides basic transport functionality for IP sockets (both TCP and UDP).

Built on top of the Socket class.

TODO: The distinction between the Socket class and this class is a bit muddled. It could stand some additional refactoring to provide a cleaner, more flexible implementation.

Properties

maxSize

protected  maxSize
  • Visibility: protected

nameServer

protected  nameServer
  • Visibility: protected

port

protected  port
  • Visibility: protected

socket

protected  socket
  • Visibility: protected

type

protected  type
  • Visibility: protected

Methods

__construct

mixed JDWX\DNSQuery\Network\IPTransport::__construct(int i_type, string i_nameserver, int i_port, null|string i_localAddress, null|int i_localPort, int i_timeout, int i_maxSize)

Create an IP transport for DNS packets.

  • Visibility: public

Arguments

  • i_type int - The type of socket to use (Socket::SOCK_DGRAM or Socket::SOCK_STREAM)
  • i_nameserver string - The nameserver to use as an IPv4 or IPv6 address.
  • i_port int - The port to use (53 is default).
  • i_localAddress null|string - The local address to use (or null for default).
  • i_localPort null|int - The local port to use (or null for default).
  • i_timeout int - The timeout in seconds to use for the socket.
  • i_maxSize int - The maximum size of an incoming packet.

getNameServer

mixed JDWX\DNSQuery\Network\ITransport::getNameServer()

Get the IPv4 or IPv6 address of the name server associated with this transport.

getPort

mixed JDWX\DNSQuery\Network\ITransport::getPort()

Get the (name server's) port number associated with this transport.

getType

int JDWX\DNSQuery\Network\ITransport::getType()

Get the type of the transport.

read

string JDWX\DNSQuery\Network\IPTransport::read(int o_size, ?int i_maxSize)

reads a response from a DNS server

  • Visibility: public

Arguments

  • o_size int - (output) Size of the DNS packet read
  • i_maxSize ?int - Max data size to be read (if null, use max size from construction).

sendData

mixed JDWX\DNSQuery\Network\IPTransport::sendData(string i_data)
  • Visibility: public

Arguments

  • i_data string

sendRequest

mixed JDWX\DNSQuery\Network\ITransport::sendRequest(\JDWX\DNSQuery\Packet\RequestPacket i_request)

Send a request over this transport.

Arguments

generateError

mixed JDWX\DNSQuery\Network\IPTransport::generateError()

Clean up a failed socket and throw the given exception.

  • Visibility: private

receiveResponse

\JDWX\DNSQuery\Packet\ResponsePacket JDWX\DNSQuery\Network\ITransport::receiveResponse()

Read a response from this transport.

Clone this wiki locally