UDP packet peer.
    public class PacketPeerUDP : PacketPeer

UDP packet peer. Can be used to send raw UDP packets as well as Variants.

Inheritance Chain

Constructors

    public PacketPeerUDP()

Methods

    public void Close()

Closes the UDP socket the PacketPeerUDP is currently listening on.

    public string GetPacketIp()

Returns the IP of the remote peer that sent the last packet(that was received with PacketPeer.GetPacket() or PacketPeer.GetVar(bool)).

    public int GetPacketPort()

Returns the port of the remote peer that sent the last packet(that was received with PacketPeer.GetPacket() or PacketPeer.GetVar(bool)).

    public bool IsListening()

Returns whether this PacketPeerUDP is listening.

    public Error JoinMulticastGroup(string multicastAddress, string interfaceName)

Joins the multicast group specified by multicastAddress using the interface identified by interfaceName.

You can join the same multicast group with multiple interfaces. Use IP.GetLocalInterfaces() to know which are available.

    public Error LeaveMulticastGroup(string multicastAddress, string interfaceName)

Removes the interface identified by interfaceName from the multicast group specified by multicastAddress.

    public Error Listen(int port, string bindAddress = "*", int recvBufSize = 65536)

Makes this PacketPeerUDP listen on the port binding to bindAddress with a buffer size recvBufSize.

If bindAddress is set to "*" (default), the peer will listen on all available addresses (both IPv4 and IPv6).

If bindAddress is set to "0.0.0.0" (for IPv4) or "::" (for IPv6), the peer will listen on all available addresses matching that IP type.

If bindAddress is set to any valid address (e.g. "192.168.1.101", "::1", etc), the peer will only listen on the interface with that addresses (or fail if no interface with the given address exists).

    public Error SetDestAddress(string host, int port)

Sets the destination address and port for sending packets and variables. A hostname will be resolved using DNS if needed.

    public Error Wait()

Waits for a packet to arrive on the listening port. See Listen(int, string, int).

Tags: