UDP

public class UDP : CallbackQueueProtocol

UDP Socket.

  • Undocumented

    Declaration

    Swift

    public typealias RecvHandler = (_ data: Data, _ ip: IP4Address, _ port: UInt16) -> Void
  • This handler will be called, once a new packet arrives.

    Declaration

    Swift

    public var recvHandler: RecvHandler?
  • Undocumented

    Declaration

    Swift

    public init(recvHandler: RecvHandler?)
  • Start dispatching events of the connection/listener and set the queue to deliver the events on.

    Declaration

    Swift

    public func start(queue: DispatchQueue)

    Parameters

    queue

    The queue to dispatch the events on

  • Undocumented

    Declaration

    Swift

    public func bind(address: IP4Address, port: UInt16) throws
  • Bind this socket to a network interface. All packets received via this socket are guaranteed to have come in via the specified NetworkInterface, and all outgoing packets will go out via the specified NetworkInterface

    Declaration

    Swift

    public func bind(interface: NetworkInterface)

    Parameters

    interface

    The network interface to bind to

  • Remove the socket.

    Declaration

    Swift

    public func disconnect()
  • Send a datagram to the current remote ip

    Declaration

    Swift

    public func send(data: Data) throws
  • Send a datagram to a remote address

    Declaration

    Swift

    public func send(data: Data, address: IP4Address, port: UInt16) throws