Home Units Hierarchy Routines All identifiers

Class unaSTUNclient

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type unaSTUNclient = class(unaSTUNagent)

Description

STUN client

Hierarchy

Overview

Methods

Public constructor create(const host: string; proto: int = C_STUN_PROTO_UDP; useDNSSRV: bool = true; const port: string = ''; const bind2ip: string = '0.0.0.0');
Public destructor Destroy(); override;
Public function req(method: int = C_STUN_MSGTYPE_BINDING; attrs: pointer = nil; attrsLen: int = 0; socket: unaSocket = nil; event: tHandle = 0): int;
Protected function doYourJob(addr: PSockAddrIn; buf: pointer; dataLen: int): bool; override;
Protected function readData(buf: pointer; maxSize: int; out addr: sockaddr_in): int; override;
Protected procedure doOpen(); override;
Protected procedure onDNSAnswer(query: unaDNSQuery); virtual;
Protected procedure onResponse4(r: unaSTUNClient_req; error: int; const ip4H: TIPv4H; port, boundPort: uint16); virtual;
Protected procedure onResponse6(r: unaSTUNClient_req; error: int; const ip6H: TIPV6H; port, boundPort: uint16); virtual;
Protected procedure startIn(); override;
Protected procedure startOut(); override;

Properties

Public property bind2port: string read f_bind2port write f_bind2port;
Public property host: string read f_host;

Description

Methods

Public constructor create(const host: string; proto: int = C_STUN_PROTO_UDP; useDNSSRV: bool = true; const port: string = ''; const bind2ip: string = '0.0.0.0');

Creates STUN client

Parameters
host
remote host
proto
UDP/TCP
useDNSSRV
Issue DNS SRV query if True, otherwise use provided host/port
port
remote server port number. If useDNSSRV is false, default port value is C_STUN_DEF_PORT
bind2ip
bind client socket to this IP
Public destructor Destroy(); override;

Destroys STUN Client object

Public function req(method: int = C_STUN_MSGTYPE_BINDING; attrs: pointer = nil; attrsLen: int = 0; socket: unaSocket = nil; event: tHandle = 0): int;

Sends a request to remote server.

Parameters
method
method to use, default is C_STUN_MSGTYPE_BINDING
attrs
pointer to additional attributes to send
attrsLen
size of additional attributes
socket
Use this socket instead of internal one
event
set this event when request is notified
Returns

internal index of request ( > 0), or -1 in case of some error

Protected function doYourJob(addr: PSockAddrIn; buf: pointer; dataLen: int): bool; override;

Send pending requests

Protected function readData(buf: pointer; maxSize: int; out addr: sockaddr_in): int; override;

Reads data from socket(s)

Protected procedure doOpen(); override;

Issue DNSSRV lookup if needed.

Protected procedure onDNSAnswer(query: unaDNSQuery); virtual;

Got DNS reply

Protected procedure onResponse4(r: unaSTUNClient_req; error: int; const ip4H: TIPv4H; port, boundPort: uint16); virtual;

Got STUN response, IPv4 address

Protected procedure onResponse6(r: unaSTUNClient_req; error: int; const ip6H: TIPV6H; port, boundPort: uint16); virtual;

Got STUN response, IPv6 address

Protected procedure startIn(); override;

Handle DNS responses if using SRV records

Protected procedure startOut(); override;

Cleans up

Properties

Public property bind2port: string read f_bind2port write f_bind2port;

Bind client to this port.

Public property host: string read f_host;

Remote STUN server host.

(c) 2012 Lake of Soft


Generated by PasDoc 0.12.1 on 2012-10-09