chronos/transports/datagram

    Dark Mode
Search:
Group by:
  Source   Edit

Types

DatagramCallback = proc (transp: DatagramTransport; remote: TransportAddress): Future[
    void] {.async: (...raises: []).}
  Source   Edit
DatagramTransport = ref object of RootRef
  fd*: AsyncFD
  state: set[TransportState]
  flags: set[ServerFlags]
  buffer: seq[byte]
  buflen: int
  error: ref TransportError
  queue: Deque[GramVector]
  local: TransportAddress
  remote: TransportAddress
  udata*: pointer
  function: DatagramCallback
  future: Future[void].Raising([])
  raddr: Sockaddr_storage
  ralen: SockLen
  waddr: Sockaddr_storage
  walen: SockLen
  when defined(windows):
      rovl: CustomOverlapped
      wovl: CustomOverlapped
      rflag: uint32
      rwsabuf: WSABUF
      wwsabuf: WSABUF

  
  Source   Edit
UnsafeDatagramCallback = proc (transp: DatagramTransport;
                               remote: TransportAddress): Future[void] {.async.}
  Source   Edit

Consts

DgramTransportTrackerName = "datagram.transport"
  Source   Edit

Procs

proc close(transp: DatagramTransport) {....raises: [], tags: [].}
Closes and frees resources of transport transp.   Source   Edit
proc closed(transp: DatagramTransport): bool {.inline, ...raises: [], tags: [].}
Returns true if transport in closed state.   Source   Edit
proc closeWait(transp: DatagramTransport): InternalRaisesFuture[void, void] {.
    stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [],
    tags: [RootEffect].}
Close transport transp and release all resources.   Source   Edit
proc getMessage(transp: DatagramTransport): seq[byte] {.
    ...raises: [TransportError], raises: [], tags: [].}
Copy data from internal message buffer and return result.   Source   Edit
proc getUserData[T](transp: DatagramTransport): T {.inline, ...raises: [].}
Obtain user data stored in transp object.   Source   Edit
proc join(transp: DatagramTransport): InternalRaisesFuture[void,
    (CancelledError,)] {.stackTrace: false, ...raises: [], gcsafe, raises: [],
                         raises: [], tags: [RootEffect].}
  Source   Edit
proc localAddress(transp: DatagramTransport): TransportAddress {.
    ...raises: [TransportOsError], raises: [], tags: [].}
Returns transp remote socket address.   Source   Edit
proc localAddress2(transp: DatagramTransport): Result[TransportAddress,
    OSErrorCode] {....raises: [], tags: [].}
Returns transp local socket address.   Source   Edit
proc newDatagramTransport(cbproc: DatagramCallback;
                          remote: TransportAddress = AnyAddress;
                          local: TransportAddress = AnyAddress;
                          sock: AsyncFD = asyncInvalidSocket;
                          flags: set[ServerFlags] = {}; udata: pointer = nil;
                          child: DatagramTransport = nil;
                          bufSize: int = DefaultDatagramBufferSize;
                          ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], raises: [], tags: [RootEffect].}

Create new UDP datagram transport (IPv4).

cbproc - callback which will be called, when new datagram received. remote - bind transport to remote address (optional). local - bind transport to local address (to serving incoming datagrams, optional) sock - application-driven socket to use. flags - flags that will be applied to socket. udata - custom argument which will be passed to cbproc. bufSize - size of internal buffer. ttl - TTL for UDP datagram packet (only usable when flags has Broadcast option).

  Source   Edit
proc newDatagramTransport(cbproc: DatagramCallback; localPort: Port;
                          local: Opt[IpAddress] = Opt.none(IpAddress);
                          flags: set[ServerFlags] = {}; udata: pointer = nil;
                          child: DatagramTransport = nil;
                          bufSize: int = DefaultDatagramBufferSize;
                          ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], raises: [], tags: [RootEffect].}
  Source   Edit
proc newDatagramTransport(cbproc: DatagramCallback; localPort: Port;
                          remotePort: Port;
                          local: Opt[IpAddress] = Opt.none(IpAddress);
                          remote: Opt[IpAddress] = Opt.none(IpAddress);
                          flags: set[ServerFlags] = {}; udata: pointer = nil;
                          child: DatagramTransport = nil;
                          bufSize: int = DefaultDatagramBufferSize;
                          ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], raises: [], tags: [RootEffect].}

Create new UDP datagram transport (IPv6) and bind it to ANY_ADDRESS. Depending on OS settings procedure perform an attempt to create transport using IPv6 ANY_ADDRESS, if its not available it will try to bind transport to IPv4 ANY_ADDRESS.

cbproc - callback which will be called, when new datagram received. localPort - local peer's port number. remotePort - remote peer's port number. local - optional local peer's IPv4/IPv6 address. remote - optional remote peer's IPv4/IPv6 address. sock - application-driven socket to use. flags - flags that will be applied to socket. udata - custom argument which will be passed to cbproc. bufSize - size of internal buffer. ttl - TTL for UDP datagram packet (only usable when flags has Broadcast option).

  Source   Edit
proc newDatagramTransport(cbproc: UnsafeDatagramCallback;
                          remote: TransportAddress = AnyAddress;
                          local: TransportAddress = AnyAddress;
                          sock: AsyncFD = asyncInvalidSocket;
                          flags: set[ServerFlags] = {}; udata: pointer = nil;
                          child: DatagramTransport = nil;
                          bufSize: int = DefaultDatagramBufferSize;
                          ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], deprecated: "Callback must not raise exceptions, annotate with {.async: (raises: []).}",
    raises: [], tags: [RootEffect].}
Deprecated: Callback must not raise exceptions, annotate with {.async: (raises: []).}

Create new UDP datagram transport (IPv4).

cbproc - callback which will be called, when new datagram received. remote - bind transport to remote address (optional). local - bind transport to local address (to serving incoming datagrams, optional) sock - application-driven socket to use. flags - flags that will be applied to socket. udata - custom argument which will be passed to cbproc. bufSize - size of internal buffer. ttl - TTL for UDP datagram packet (only usable when flags has Broadcast option).

  Source   Edit
proc newDatagramTransport6(cbproc: DatagramCallback;
                           remote: TransportAddress = AnyAddress6;
                           local: TransportAddress = AnyAddress6;
                           sock: AsyncFD = asyncInvalidSocket;
                           flags: set[ServerFlags] = {}; udata: pointer = nil;
                           child: DatagramTransport = nil;
                           bufSize: int = DefaultDatagramBufferSize;
                           ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], raises: [], tags: [RootEffect].}

Create new UDP datagram transport (IPv6).

cbproc - callback which will be called, when new datagram received. remote - bind transport to remote address (optional). local - bind transport to local address (to serving incoming datagrams, optional) sock - application-driven socket to use. flags - flags that will be applied to socket. udata - custom argument which will be passed to cbproc. bufSize - size of internal buffer. ttl - TTL for UDP datagram packet (only usable when flags has Broadcast option).

  Source   Edit
proc newDatagramTransport6(cbproc: UnsafeDatagramCallback;
                           remote: TransportAddress = AnyAddress6;
                           local: TransportAddress = AnyAddress6;
                           sock: AsyncFD = asyncInvalidSocket;
                           flags: set[ServerFlags] = {}; udata: pointer = nil;
                           child: DatagramTransport = nil;
                           bufSize: int = DefaultDatagramBufferSize;
                           ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], deprecated: "Callback must not raise exceptions, annotate with {.async: (raises: []).}",
    raises: [], tags: [RootEffect].}
Deprecated: Callback must not raise exceptions, annotate with {.async: (raises: []).}

Create new UDP datagram transport (IPv6).

cbproc - callback which will be called, when new datagram received. remote - bind transport to remote address (optional). local - bind transport to local address (to serving incoming datagrams, optional) sock - application-driven socket to use. flags - flags that will be applied to socket. udata - custom argument which will be passed to cbproc. bufSize - size of internal buffer. ttl - TTL for UDP datagram packet (only usable when flags has Broadcast option).

  Source   Edit
proc newDatagramTransport6[T](cbproc: DatagramCallback; udata: ref T;
                              remote: TransportAddress = AnyAddress6;
                              local: TransportAddress = AnyAddress6;
                              sock: AsyncFD = asyncInvalidSocket;
                              flags: set[ServerFlags] = {};
                              child: DatagramTransport = nil;
                              bufSize: int = DefaultDatagramBufferSize;
                              ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], raises: [].}
  Source   Edit
proc newDatagramTransport6[T](cbproc: UnsafeDatagramCallback; udata: ref T;
                              remote: TransportAddress = AnyAddress6;
                              local: TransportAddress = AnyAddress6;
                              sock: AsyncFD = asyncInvalidSocket;
                              flags: set[ServerFlags] = {};
                              child: DatagramTransport = nil;
                              bufSize: int = DefaultDatagramBufferSize;
                              ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], deprecated: "Callback must not raise exceptions, annotate with {.async: (raises: []).}",
    raises: [].}
Deprecated: Callback must not raise exceptions, annotate with {.async: (raises: []).}
  Source   Edit
proc newDatagramTransport[T](cbproc: DatagramCallback; localPort: Port;
                             local: Opt[IpAddress] = Opt.none(IpAddress);
                             flags: set[ServerFlags] = {}; udata: ref T;
                             child: DatagramTransport = nil;
                             bufSize: int = DefaultDatagramBufferSize;
                             ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], raises: [].}
  Source   Edit
proc newDatagramTransport[T](cbproc: DatagramCallback; localPort: Port;
                             remotePort: Port;
                             local: Opt[IpAddress] = Opt.none(IpAddress);
                             remote: Opt[IpAddress] = Opt.none(IpAddress);
                             flags: set[ServerFlags] = {}; udata: ref T;
                             child: DatagramTransport = nil;
                             bufSize: int = DefaultDatagramBufferSize;
                             ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], raises: [].}
  Source   Edit
proc newDatagramTransport[T](cbproc: DatagramCallback; udata: ref T;
                             remote: TransportAddress = AnyAddress;
                             local: TransportAddress = AnyAddress;
                             sock: AsyncFD = asyncInvalidSocket;
                             flags: set[ServerFlags] = {};
                             child: DatagramTransport = nil;
                             bufSize: int = DefaultDatagramBufferSize;
                             ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], raises: [].}
  Source   Edit
proc newDatagramTransport[T](cbproc: UnsafeDatagramCallback; udata: ref T;
                             remote: TransportAddress = AnyAddress;
                             local: TransportAddress = AnyAddress;
                             sock: AsyncFD = asyncInvalidSocket;
                             flags: set[ServerFlags] = {};
                             child: DatagramTransport = nil;
                             bufSize: int = DefaultDatagramBufferSize;
                             ttl: int = 0; dualstack = DualStackType.Auto): DatagramTransport {.
    ...raises: [TransportOsError], deprecated: "Callback must not raise exceptions, annotate with {.async: (raises: []).}",
    raises: [].}
Deprecated: Callback must not raise exceptions, annotate with {.async: (raises: []).}
  Source   Edit
proc peekMessage(transp: DatagramTransport; msg: var seq[byte]; msglen: var int) {.
    ...raises: [TransportError], raises: [], tags: [].}
Get access to internal message buffer and length of incoming datagram.   Source   Edit
proc remoteAddress(transp: DatagramTransport): TransportAddress {.
    ...raises: [TransportOsError], raises: [], tags: [].}
Returns transp remote socket address.   Source   Edit
proc remoteAddress2(transp: DatagramTransport): Result[TransportAddress,
    OSErrorCode] {....raises: [], tags: [].}
Returns transp remote socket address.   Source   Edit
proc send(transp: DatagramTransport; msg: string; msglen = -1): InternalRaisesFuture[
    void, (TransportError, CancelledError)] {.stackTrace: false, ...raises: [],
    gcsafe, raises: [], raises: [], tags: [RootEffect].}
  Source   Edit
proc send(transp: DatagramTransport; pbytes: pointer; nbytes: int): InternalRaisesFuture[
    void, (TransportError, CancelledError)] {.stackTrace: false, ...raises: [],
    gcsafe, raises: [], raises: [], tags: [].}
  Source   Edit
proc send[T](transp: DatagramTransport; msg: seq[T]; msglen = -1): InternalRaisesFuture[
    void, (TransportError, CancelledError)] {.stackTrace: false, ...raises: [],
    gcsafe, raises: [], raises: [].}
  Source   Edit
proc sendTo(transp: DatagramTransport; remote: TransportAddress; msg: string;
            msglen = -1): InternalRaisesFuture[void,
    (TransportError, CancelledError)] {.stackTrace: false, ...raises: [], gcsafe,
                                        raises: [], raises: [],
                                        tags: [RootEffect].}
  Source   Edit
proc sendTo(transp: DatagramTransport; remote: TransportAddress;
            pbytes: pointer; nbytes: int): InternalRaisesFuture[void,
    (TransportError, CancelledError)] {.stackTrace: false, ...raises: [], gcsafe,
                                        raises: [], raises: [], tags: [].}
  Source   Edit
proc sendTo[T](transp: DatagramTransport; remote: TransportAddress; msg: seq[T];
               msglen = -1): InternalRaisesFuture[void,
    (TransportError, CancelledError)] {.stackTrace: false, ...raises: [], gcsafe,
                                        raises: [], raises: [].}
  Source   Edit