Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions

PUDPSocket Class Reference

#include <udpsock.h>

Inheritance diagram for PUDPSocket:
Inheritance graph
Collaboration diagram for PUDPSocket:
Collaboration graph

List of all members.

Public Types

enum  PXBlockType { PXReadBlock, PXWriteBlock, PXAcceptBlock, PXConnectBlock }

Public Member Functions

virtual BOOL Connect (const Address &addr)
virtual BOOL Connect (WORD localPort, const Address &addr)
virtual BOOL Connect (const Address &iface, const Address &addr)
virtual BOOL Connect (const Address &iface, WORD localPort, const Address &addr)
PIPSocket::Address GetLastReceiveToAddress () const
virtual BOOL GetLocalAddress (Address &addr)
virtual BOOL GetLocalAddress (Address &addr, WORD &port)
PString GetLocalHostName ()
virtual PString GetName () const
virtual BOOL GetPeerAddress (Address &addr, WORD &port)
virtual BOOL GetPeerAddress (Address &addr)
PString GetPeerHostName ()
virtual BOOL Listen (const Address &bind, unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive)
virtual BOOL Listen (unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive)
 PLIST (RouteTable, RouteEntry)
 PLIST (InterfaceTable, InterfaceEntry)
virtual BOOL ReadFrom (void *buf, PINDEX len, Address &addr, WORD &port)
BOOL SetCaptureReceiveToAddress ()
virtual BOOL WriteTo (const void *buf, PINDEX len, const Address &addr, WORD port)
 PUDPSocket (WORD port=0)
 PUDPSocket (PQoS *qos, WORD port=0)
 PUDPSocket (const PString &service, PQoS *qos=NULL)
 PUDPSocket (const PString &address, WORD port)
 PUDPSocket (const PString &address, const PString &service)
Overrides from class PSocket
BOOL Read (void *buf, PINDEX len)
BOOL Write (const void *buf, PINDEX len)
BOOL Connect (const PString &address)
Socket options functions
BOOL SetOption (int option, int value, int level=SOL_SOCKET)
BOOL SetOption (int option, const void *valuePtr, PINDEX valueSize, int level=SOL_SOCKET)
BOOL GetOption (int option, int &value, int level=SOL_SOCKET)
BOOL GetOption (int option, void *valuePtr, PINDEX valueSize, int level=SOL_SOCKET)
Overrides from class PObject
virtual Comparison Compare (const PObject &obj) const
virtual PINDEX HashFunction () const
Information functions
virtual BOOL IsOpen () const
int GetHandle () const
virtual PChannelGetBaseReadChannel () const
virtual PChannelGetBaseWriteChannel () const
Reading functions
void SetReadTimeout (const PTimeInterval &time)
PTimeInterval GetReadTimeout () const
virtual PINDEX GetLastReadCount () const
virtual int ReadChar ()
BOOL ReadBlock (void *buf, PINDEX len)
PString ReadString (PINDEX len)
virtual BOOL ReadAsync (void *buf, PINDEX len)
virtual void OnReadComplete (void *buf, PINDEX len)
Writing functions
void SetWriteTimeout (const PTimeInterval &time)
PTimeInterval GetWriteTimeout () const
virtual PINDEX GetLastWriteCount () const
BOOL WriteChar (int c)
BOOL WriteString (const PString &str)
virtual BOOL WriteAsync (const void *buf, PINDEX len)
virtual void OnWriteComplete (const void *buf, PINDEX len)
Miscellaneous functions
virtual PObjectClone () const

Static Public Member Functions

static void ClearNameCache ()
static BOOL ConvertOSError (int libcReturnValue, Errors &lastError, int &osError)
static int GetDefaultIpAddressFamily ()
static PIPSocket::Address GetDefaultIpAny ()
static BOOL GetGatewayAddress (Address &addr)
static PString GetGatewayInterface ()
static BOOL GetHostAddress (const PString &hostname, Address &addr)
static BOOL GetHostAddress (Address &addr)
static PStringArray GetHostAliases (const PString &hostname)
static PStringArray GetHostAliases (const Address &addr)
static PString GetHostName ()
static PString GetHostName (const PString &hostname)
static PString GetHostName (const Address &addr)
static BOOL GetInterfaceTable (InterfaceTable &table)
static BOOL GetNetworkInterface (PIPSocket::Address &addr)
static BOOL GetRouteTable (RouteTable &table)
static BOOL IsLocalHost (const PString &hostname)
static void SetDefaultIpAddressFamily (int ipAdressFamily)
static void SetDefaultIpAddressFamilyV4 ()
Multiple socket selection functions
static int Select (PSocket &sock1, PSocket &sock2)
static int Select (PSocket &sock1, PSocket &sock2, const PTimeInterval &timeout)
static Errors Select (SelectList &read)
static Errors Select (SelectList &read, const PTimeInterval &timeout)
static Errors Select (SelectList &read, SelectList &write)
static Errors Select (SelectList &read, SelectList &write, const PTimeInterval &timeout)
static Errors Select (SelectList &read, SelectList &write, SelectList &except)
static Errors Select (SelectList &read, SelectList &write, SelectList &except, const PTimeInterval &timeout)
Integer conversion functions
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.

Protected Member Functions

virtual BOOL ApplyQoS ()
virtual BOOL ConvertOSError (int libcReturnValue, ErrorGroup group=LastGeneralError)
virtual const char * GetProtocolName () const
virtual BOOL OpenSocket (int ipAdressFamily)
virtual BOOL OpenSocket ()
virtual int OpenSocketGQOS (int af, int type, int proto)
BOOL os_accept (PSocket &listener, struct sockaddr *addr, PINDEX *size)
int os_close ()
BOOL os_connect (struct sockaddr *sin, PINDEX size)
BOOL os_recvfrom (void *buf, PINDEX len, int flags, struct sockaddr *from, PINDEX *fromlen)
BOOL os_sendto (const void *buf, PINDEX len, int flags, struct sockaddr *to, PINDEX tolen)
int os_socket (int af, int type, int proto)
int PXClose ()
BOOL PXSetIOBlock (PXBlockType type, const PTimeInterval &timeout)
int ReadCharWithTimeout (PTimeInterval &timeout)
BOOL ReceiveCommandString (int nextChar, const PString &reply, PINDEX &pos, PINDEX start)
BOOL SetErrorValues (Errors errorCode, int osError, ErrorGroup group=LastGeneralError)

Protected Attributes

PString channelName
Errors lastErrorCode [NumErrorGroups+1]
 The platform independant error code.
int lastErrorNumber [NumErrorGroups+1]
 The operating system error number (eg as returned by errno).
PINDEX lastReadCount
 Number of byte last read by the Read() function.
Address lastReceiveAddress
WORD lastReceivePort
PINDEX lastWriteCount
 Number of byte last written by the Write() function.
int os_handle
 The operating system file handle return by standard open() function.
WORD port
 Port to be used by the socket when opening the channel.
PXBlockType px_lastBlockType
PMutex px_selectMutex
PMutex px_threadMutex
PMutex px_writeMutex
PQoS qosSpec
PTimeInterval readTimeout
 Timeout for read operations.
Address sendAddress
WORD sendPort
PTimeInterval writeTimeout
 Timeout for write operations.

Private Member Functions

 PCLASSINFO (PUDPSocket, PIPDatagramSocket)

New functions for class

void SetSendAddress (const Address &address, WORD port)
void GetSendAddress (Address &address, WORD &port)
virtual BOOL ModifyQoSSpec (PQoS *qos)
void GetLastReceiveAddress (Address &address, WORD &port)
static BOOL SupportQoS (const PIPSocket::Address &address)
static void EnableGQoS ()

I/O functions

virtual void ReadFrom (istream &strm)
virtual void PrintOn (ostream &strm) const
ostream & operator<< (ostream &strm, const PObject &obj)
istream & operator>> (istream &strm, PObject &obj)

Socket establishment functions

virtual BOOL Accept (PSocket &socket)
virtual BOOL Shutdown (ShutdownValue option)
enum  Reusability { CanReuseAddress, AddressIsExclusive }

Flags to reuse of port numbers in Listen() function.

Port/Service database functions

virtual WORD GetPortByService (const PString &service) const
virtual PString GetServiceByPort (WORD port) const
void SetPort (WORD port)
void SetPort (const PString &service)
WORD GetPort () const
PString GetService () const
static WORD GetProtocolByName (const PString &name)
static PString GetNameByProtocol (WORD proto)
static WORD GetPortByService (const char *protocol, const PString &service)
static PString GetServiceByPort (const char *protocol, WORD port)

Scattered read/write functions

virtual BOOL Read (const VectorOfSlice &slices)
virtual BOOL Write (const VectorOfSlice &slices)
typedef std::vector< SliceVectorOfSlice

Miscellaneous functions

virtual BOOL Close ()
BOOL SetBufferSize (PINDEX newSize)
BOOL SendCommandString (const PString &command)
void AbortCommandString ()
enum  ShutdownValue { ShutdownRead = 0, ShutdownWrite = 1, ShutdownReadAndWrite = 2 }

Error functions

Errors GetErrorCode (ErrorGroup group=NumErrorGroups) const
int GetErrorNumber (ErrorGroup group=NumErrorGroups) const
virtual PString GetErrorText (ErrorGroup group=NumErrorGroups) const
static PString GetErrorText (Errors lastError, int osError=0)
enum  Errors {
  NoError, NotFound, FileExists, DiskFull,
  AccessDenied, DeviceInUse, BadParameter, NoMemory,
  NotOpen, Timeout, Interrupted, BufferTooSmall,
  Miscellaneous, ProtocolFailure, NumNormalisedErrors
enum  ErrorGroup { LastReadError, LastWriteError, LastGeneralError, NumErrorGroups }

Run Time Type functions

virtual const char * GetClass (unsigned=0) const
BOOL IsClass (const char *cls) const
virtual BOOL InternalIsDescendant (const char *clsName) const
static const char * Class ()

Comparison functions

virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
bool operator== (const PObject &obj) const
bool operator!= (const PObject &obj) const
bool operator< (const PObject &obj) const
bool operator> (const PObject &obj) const
bool operator<= (const PObject &obj) const
bool operator>= (const PObject &obj) const
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }

Detailed Description

A socket channel that uses the UDP transport on the Internet Protocol.

Definition at line 135 of file udpsock.h.

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

Generated by  Doxygen 1.6.0   Back to index