UDPSocket Class Reference

[APE Index] [APE Hierarchy] [Headers]


Unreliable Datagram Protocol sockets. More...

#include <socket.h>

Inherits: Socket

Public Members


Detailed Description

UDP sockets implement the TCP SOCK_DGRAM UDP protocol. They can be used to pass unverified messages between hosts, or to broadcast a specific message to an entire subnet. Please note that Streaming of realtime data commonly use UDPSimplex or UDPDuplex rather than UDPSocket.


UDPSocket(void) [public]

Create an unbound UDP socket, mostly for internal use.

UDPSocket(InetAddress &bind, short port) [public]

Create a UDP socket and bind it to a specific interface and port address so that other UDP sockets on remote machines (or the same host) may find and send UDP messages to it. On failure to bind, an exception is thrown.

Parameters:
port number to bind this socket to.
bind address to bind this socket to.

UDPSocket(InetHostAddress &host, short port) [public]

Create a UDP socket that is connected to another UDP socket. While a UDP socket "connection" has no tangible resource unlike with TCP, it does prevent the socket from accepting UDP packets from any socket other than the one that it is connected to.

Parameters:
port number to connect the local socket to.
host address to connect the local socket to.

UDPSocket(BroadcastAddress &cast, short port) [public]

Bind a UDP socket for use in sending subnet broadcast messages. This enables the SO_BROADCAST attribute of the socket.

Parameters:
cast address of subnet to broadcast messages on.
port number to receive messages from other broadcasters.

int Write(InetHostAddress &host, short port, void *addr, size_t len) [public]

Write a UDP message of arbitrary bytes. Each write genorates a unique UDP message of the specified length, rather than simply writing data to a stream. Hence, if one is writing a message composed of a header and data segment, all of which are meant to be sent as one UDP message, then one must do so in a single Write operation or through the use of writev.

Parameters:
addr pointer to UDP message data.
port number of destination socket.
host internet address of destination socket.
len number of bytes in UDP message.
Returns:
number of bytes sent on success, -1 on error.

  • Author: David Sugar <dyfet@ostel.com>.
  • Documentation generated by dyfet@home.sys on Thu Dec 16 09:54:26 EST 1999
Kdoc