Abstractions for networking operations over sockets.
Types
AsyncListener[Protocol] = distinct AsyncSocket
- An asynchronous listener with Protocol. Source Edit
IncompatibleEndpointError = object of CatchableError
- Raised when connect or listen is used with ResolverResult but there are no compatible endpoint found. Source Edit
ResolverError = object of CatchableError errorCode*: int32 ## The error code as returned by the resolver. This value is platform-dependant.
- The exception type for errors during resolving that is not caused by the OS. Source Edit
ResolverResult = ref ResolverResultImpl
- The result of a resolve() operation Source Edit
ResolverResultImpl = object
- Source Edit
Procs
proc `=copy`(dst: var ResolverResultImpl; src: ResolverResultImpl) {.error.}
- Copying a ResolverResult is prohibited at the moment. This restriction might be lifted in the future. Source Edit
proc accept(l: AsyncListener[TCP]): tuple[conn: AsyncConn[TCP], remote: IPEndpoint] {....raises: [OSError], tags: [], forbids: [].}
-
Get the first connection from the queue of pending connections of l.
Returns the connection and its endpoint.
Source Edit proc accept(l: AsyncListener[Unix]): AsyncConn[Unix] {....raises: [OSError], tags: [], forbids: [].}
- Return the first connection from the queue of pending connections of l. Source Edit
proc connectTcp(endpoint: IP4Endpoint): Conn[TCP] {....raises: [OSError], tags: [], forbids: [].}
- Create a TCP connection to endpoint. Source Edit
proc connectTcp(endpoint: IP6Endpoint): Conn[TCP] {....raises: [OSError], tags: [], forbids: [].}
- Create a TCP connection to endpoint. Source Edit
proc connectTcp(endpoint: IPEndpoint): Conn[TCP] {....raises: [OSError], tags: [], forbids: [].}
- Create a TCP connection to endpoint. Source Edit
proc connectTcp(endpoints: ResolverResult): Conn[TCP] {. ...raises: [OSError, IncompatibleEndpointError], tags: [], forbids: [].}
-
Connects via TCP to one of the compatible endpoint from endpoints.
The first endpoint to connect successfully will be used.
If there are no compatible addresses in endpoints, IncompatibleEndpointError will be raised.
If connection fails for all endpoints, the OSError raised will be of the last endpoint tried.
Source Edit proc connectTcp(host: IP4; port: Port): Conn[TCP] {.inline, ...raises: [OSError], tags: [], forbids: [].}
- Create a TCP connection to host and port. Source Edit
proc connectTcp(host: IP6; port: Port): Conn[TCP] {.inline, ...raises: [OSError], tags: [], forbids: [].}
- Create a TCP connection to host and port. Source Edit
proc connectTcp(host: string; port: Port): Conn[TCP] {.inline, ...raises: [OSError, ResolverError, IncompatibleEndpointError], tags: [], forbids: [].}
-
Create a TCP connection to host and port.
host will be resolved before connection.
Source Edit proc connectTcpAsync(endpoint: IP4Endpoint): AsyncConn[TCP] {....raises: [OSError], tags: [], forbids: [].}
-
Create an asynchronous TCP connection to endpoint.
OSError is raised if the connection fails.
Source Edit proc connectTcpAsync(endpoint: IP6Endpoint): AsyncConn[TCP] {....raises: [OSError], tags: [], forbids: [].}
-
Create an asynchronous TCP connection to endpoint.
OSError is raised if the connection fails.
Source Edit proc connectTcpAsync(endpoint: IPEndpoint): AsyncConn[TCP] {....raises: [OSError], tags: [], forbids: [].}
-
Create an asynchronous TCP connection to endpoint.
OSError is raised if the connection fails.
Source Edit proc connectTcpAsync(endpoints: ResolverResult): AsyncConn[TCP] {. ...raises: [Exception, IncompatibleEndpointError, OSError], tags: [RootEffect], forbids: [].}
-
Connects via TCP to one of the compatible endpoint from endpoints.
The first endpoint to connect successfully will be used.
If there are no compatible addresses in endpoints, IncompatibleEndpointError will be raised.
If connection fails for all endpoints, the OSError raised will be of the last endpoint tried.
Note: It might be necessary to perform an explicit move into this parameter.
Source Edit proc connectTcpAsync(host: IP4; port: Port): AsyncConn[TCP] {....raises: [OSError], tags: [], forbids: [].}
- Create a TCP connection to host and port. Source Edit
proc connectTcpAsync(host: IP6; port: Port): Conn[TCP] {.inline, ...raises: [OSError], tags: [], forbids: [].}
- Create a TCP connection to host and port. Source Edit
proc connectTcpAsync(host: string; port: Port): AsyncConn[TCP] {. ...raises: [OSError, ResolverError, Exception, IncompatibleEndpointError], tags: [RootEffect], forbids: [].}
-
Create a TCP connection to host and port.
host will be resolved synchronously before connection.
Source Edit proc connectUnix(path: string): Conn[Unix] {....raises: [OSError], tags: [], forbids: [].}
-
Create a connection to the Unix socket at path.
Unix sockets are currently only supported on POSIX-like platforms (this does not include Windows). Unix socket implementations can differ in the maximum supported length of path elements as well as the total path length. On Linux the maximum path length is hardcoded to 107 characters.
Source Edit proc connectUnixAsync(path: string): AsyncConn[Unix] {....raises: [OSError], tags: [], forbids: [].}
-
Create an asynchronous connection to the Unix socket at path.
Unix sockets are currently only supported on POSIX-like platforms (this does not include Windows). Unix socket implementations can differ in the maximum supported length of path elements as well as the total path length. On Linux the maximum path length is hardcoded to 107 characters.
Source Edit proc listenTcp(endpoint: IP4Endpoint; backlog = none(Natural)): Listener[TCP] {. ...raises: [OSError], tags: [], forbids: [].}
-
Listen at endpoint for TCP connections.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcp(endpoint: IP6Endpoint; backlog = none(Natural)): Listener[TCP] {. ...raises: [OSError], tags: [], forbids: [].}
-
Listen at endpoint for TCP connections.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcp(endpoint: IPEndpoint; backlog = none(Natural)): Listener[TCP] {. ...raises: [OSError], tags: [], forbids: [].}
-
Listen at endpoint for TCP connections.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcp(endpoints: ResolverResult; backlog = none(Natural)): Listener[TCP] {. ...raises: [OSError, IncompatibleEndpointError], tags: [], forbids: [].}
-
Listen for TCP connections at one of the endpoint in endpoints.
The first endpoint listened to successfully will be used.
If there are no compatible addresses in endpoints, IncompatibleEndpointError will be raised.
If listening fails for all endpoints, the OSError raised will be of the last endpoint tried.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcp(host: IP4; port: Port; backlog = none(Natural)): Listener[TCP] {. inline, ...raises: [OSError], tags: [], forbids: [].}
-
Listen at host and port for TCP connections.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to fetch this data.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcp(host: IP6; port: Port; backlog = none(Natural)): Listener[TCP] {. inline, ...raises: [OSError], tags: [], forbids: [].}
-
Listen at host and port for TCP connections.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to fetch this data.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcp(host: string; port: Port; kind = none(IPEndpointKind); backlog = none(Natural)): Listener[TCP] {.inline, ...raises: [OSError, IncompatibleEndpointError, ResolverError], tags: [], forbids: [].}
-
Listen at host and port for TCP connections.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcpAsync(endpoint: IP4Endpoint; backlog: Option[Natural] = none(Natural)): AsyncListener[TCP] {. ...raises: [OSError], tags: [], forbids: [].}
-
Listen at endpoint for TCP connections asynchronously.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcpAsync(endpoint: IP6Endpoint; backlog: Option[Natural] = none(Natural)): AsyncListener[TCP] {. ...raises: [OSError], tags: [], forbids: [].}
-
Listen at endpoint for TCP connections asynchronously.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcpAsync(endpoint: IPEndpoint; backlog: Option[Natural] = none(Natural)): AsyncListener[TCP] {. ...raises: [OSError], tags: [], forbids: [].}
-
Listen at endpoint for TCP connections asynchronously.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcpAsync(endpoints: ResolverResult; backlog: Option[Natural] = none(Natural)): AsyncListener[TCP] {. ...raises: [Exception, IncompatibleEndpointError, OSError], tags: [RootEffect], forbids: [].}
-
Listen for TCP connections at one of the endpoint in endpoints.
The first endpoint listened to successfully will be used.
If there are no compatible addresses in endpoints, IncompatibleEndpointError will be raised.
If listening fails for all endpoints, the OSError raised will be of the last endpoint tried.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
Note: It might be necessary to perform an explicit move into this parameter.
Source Edit proc listenTcpAsync(host: IP4; port: Port; backlog: Option[Natural] = none(Natural)): AsyncListener[TCP] {. ...raises: [OSError], tags: [], forbids: [].}
-
Listen at host and port for TCP connections.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcpAsync(host: IP6; port: Port; backlog: Option[Natural] = none(Natural)): AsyncListener[TCP] {. ...raises: [OSError], tags: [], forbids: [].}
-
Listen at host and port for TCP connections.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenTcpAsync(host: string; port: Port; kind: Option[IPEndpointKind] = none(IPEndpointKind); backlog: Option[Natural] = none(Natural)): AsyncListener[TCP] {. ...raises: [Exception, IncompatibleEndpointError, OSError, ResolverError], tags: [RootEffect], forbids: [].}
-
Listen at host and port for TCP connections.
If the port of the endpoint is PortNone, an ephemeral port will be reserved automatically by the operating system. localEndpoint can be used to retrieve the port number.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Source Edit proc listenUnix(path: string; backlog = none(Natural)): Listener[Unix] {. ...raises: [OSError], tags: [], forbids: [].}
-
Listen at path for Unix socket connections.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Unix sockets are currently only supported on POSIX-like platforms (this does not include Windows). Unix socket implementations can differ in the maximum supported length of path elements as well as the total path length. On Linux the maximum path length is hardcoded to 107 characters.
Source Edit proc listenUnixAsync(path: string; backlog: Option[Natural] = none(Natural)): AsyncListener[ Unix] {....raises: [OSError], tags: [], forbids: [].}
-
Listen at path for Unix socket connections asynchronously.
The backlog parameter defines the maximum amount of pending connections. If a connection request arrives when the queue is full, the client might receive a "Connection refused" error or the connection might be silently dropped. This value is treated by most operating systems as a hint.
If backlog is None, the maximum queue length will be selected.
If backlog is 0, the OS will select a reasonable minimum.
Unix sockets are currently only supported on POSIX-like platforms (this does not include Windows). Unix socket implementations can differ in the maximum supported length of path elements as well as the total path length. On Linux the maximum path length is hardcoded to 107 characters.
Source Edit proc localEndpoint(l: AsyncListener[TCP] | Listener[TCP]): IPEndpoint {. ...raises: [OSError].}
- Obtain the local endpoint of l. Source Edit
proc newAsyncSocket(fd: SocketFD): AsyncSocket {.inline, ...raises: [], tags: [], forbids: [].}
-
Creates a new AsyncSocket from an opened socket handle.
The ownership of the handle will be transferred to the resulting Socket.
Note: It is assumed that the handle has been opened in asynchronous mode. Only use this interface if you know what you are doing.
Platform specific details
- On POSIX, it is assumed that fd is opened with O_NONBLOCK set.
- On Windows, it is assumed that fd is opened in overlapped mode.
proc newAsyncSocket(handle: sink Handle[SocketFD]): AsyncSocket {.inline, ...raises: [], tags: [], forbids: [].}
-
Creates a new AsyncSocket from an opened socket handle.
The ownership of the handle will be transferred to the resulting Socket.
Note: It is assumed that the handle has been opened in asynchronous mode. Only use this interface if you know what you are doing.
Platform specific details
- On POSIX, it is assumed that fd is opened with O_NONBLOCK set.
- On Windows, it is assumed that fd is opened in overlapped mode.
func newIncompatibleEndpointError(): ref IncompatibleEndpointError {.inline, ...raises: [], tags: [], forbids: [].}
- Create an instance of IncompatibleAddressError. Source Edit
proc newSocket(fd: SocketFD): Socket {.inline, ...raises: [], tags: [], forbids: [].}
-
Creates a new Socket from an opened socket handle.
The ownership of the handle will be transferred to the resulting Socket.
Note: It is assumed that the handle has been opened in synchronous mode. Only use this interface if you know what you are doing.
Platform specific details
- On Windows, sockets created via Winsock socket() function are opened in overlapped mode and should be passed to newAsyncSocket <#newAsyncSocket.SocketFD> instead.
proc newSocket(handle: sink Handle[SocketFD]): Socket {.inline, ...raises: [], tags: [], forbids: [].}
-
Creates a new Socket from an opened socket handle.
The ownership of the handle will be transferred to the resulting Socket.
Note: It is assumed that the handle has been opened in synchronous mode. Only use this interface if you know what you are doing.
Platform specific details
- On Windows, sockets created via Winsock socket() function are opened in overlapped mode and should be passed to newAsyncSocket <#newAsyncSocket.SocketFD> instead.
proc read(s: AsyncConn[Protocol(0)]; b: ref seq[byte]): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Reads up to b.len bytes from socket s into b.
This is an overload of read(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc read(s: AsyncConn[Protocol(0)]; b: ref string): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Reads up to b.len bytes from socket s into b.
This is an overload of read(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc read(s: AsyncConn[Protocol(0)]; buf: ptr UncheckedArray[byte]; bufLen: Natural): int {....raises: [ValueError, IOError], tags: [], forbids: [].}
-
Reads up to bufLen bytes from socket s into buf.
buf must stays alive for the duration of the operation. Direct usage of this interface is discouraged due to its unsafetyness. Users are encouraged to use the high-level overloads that keep buffers alive.
If the other endpoint is closed, no data will be read and no error will be raised.
Returns the number of bytes read from s.
Platform specific details
- On POSIX systems, signals will not interrupt the operation.
proc read(s: AsyncConn[Protocol(1)]; b: ref seq[byte]): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Reads up to b.len bytes from socket s into b.
This is an overload of read(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc read(s: AsyncConn[Protocol(1)]; b: ref string): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Reads up to b.len bytes from socket s into b.
This is an overload of read(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc read(s: AsyncConn[Protocol(1)]; buf: ptr UncheckedArray[byte]; bufLen: Natural): int {....raises: [ValueError, IOError], tags: [], forbids: [].}
-
Reads up to bufLen bytes from socket s into buf.
buf must stays alive for the duration of the operation. Direct usage of this interface is discouraged due to its unsafetyness. Users are encouraged to use the high-level overloads that keep buffers alive.
If the other endpoint is closed, no data will be read and no error will be raised.
Returns the number of bytes read from s.
Platform specific details
- On POSIX systems, signals will not interrupt the operation.
proc read[T: byte or char](s: Conn; b: var openArray[T]): int
-
Reads up to b.len bytes from socket s into b.
If the other endpoint is closed, no data will be read and no error will be raised.
Returns the number of bytes read from s.
Platform specific details
- On POSIX systems, signals will not interrupt the operation if nothing was read.
proc resolveIP(host: string; port: Port = PortNone; kind = none(IPEndpointKind)): ResolverResult {. ...raises: [OSError, ResolverError], tags: [], forbids: [].}
-
Resolve the endpoints of host for port port.
port will be carried over to the result verbatim.
kind can be specified to limit the result to the specified endpoint address family.
On failure, either OSError or ResolverError will be raised, depending on whether the error was caused by the operating system or the resolver.
Platform specific details
- On POSIX, the error code in ResolverError will be the error returned via getaddrinfo() function.
- On Windows, the error code in ResolverError is one of the errors in this list. Other errors are reported as OSError.
proc write(s: AsyncConn[Protocol(0)]; b: ref seq[byte]): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Writes up to b.len bytes from b into socket s.
This is an overload of write(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc write(s: AsyncConn[Protocol(0)]; b: ref string): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Writes up to b.len bytes from b to socket s.
This is an overload of write(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc write(s: AsyncConn[Protocol(0)]; b: seq[byte]): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Writes up to b.len bytes from b to socket s. The contents of b will be copied prior to the operation. Consider the ref overload to avoid copies.
This is an overload of write(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc write(s: AsyncConn[Protocol(0)]; b: string): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Writes up to b.len bytes from b to socket s. The contents of b will be copied prior to the operation. Consider the ref overload to avoid copies.
This is an overload of write(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc write(s: AsyncConn[Protocol(0)]; buf: ptr UncheckedArray[byte]; bufLen: Natural): int {....raises: [ValueError, IOError], tags: [], forbids: [].}
-
Writes up to bufLen bytes from buf to socket s.
buf must stays alive for the duration of the operation. Direct usage of this interface is discouraged due to its unsafetyness. Users are encouraged to use the high-level overloads that keep the buffer alive.
Returns the number of bytes written into s.
Platform specific details
- On POSIX systems, signals will not interrupt the operation.
proc write(s: AsyncConn[Protocol(1)]; b: ref seq[byte]): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Writes up to b.len bytes from b into socket s.
This is an overload of write(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc write(s: AsyncConn[Protocol(1)]; b: ref string): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Writes up to b.len bytes from b to socket s.
This is an overload of write(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc write(s: AsyncConn[Protocol(1)]; b: seq[byte]): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Writes up to b.len bytes from b to socket s. The contents of b will be copied prior to the operation. Consider the ref overload to avoid copies.
This is an overload of write(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc write(s: AsyncConn[Protocol(1)]; b: string): int {. ...raises: [ValueError, IOError], tags: [], forbids: [].}
-
Writes up to b.len bytes from b to socket s. The contents of b will be copied prior to the operation. Consider the ref overload to avoid copies.
This is an overload of write(s, buf, bufLen), plese refer to its documentation for more information.
Source Edit proc write(s: AsyncConn[Protocol(1)]; buf: ptr UncheckedArray[byte]; bufLen: Natural): int {....raises: [ValueError, IOError], tags: [], forbids: [].}
-
Writes up to bufLen bytes from buf to socket s.
buf must stays alive for the duration of the operation. Direct usage of this interface is discouraged due to its unsafetyness. Users are encouraged to use the high-level overloads that keep the buffer alive.
Returns the number of bytes written into s.
Platform specific details
- On POSIX systems, signals will not interrupt the operation.
Iterators
iterator items(r: ResolverResult): IPEndpoint {....raises: [], tags: [], forbids: [].}
- Yields endpoints from the resolving result Source Edit
Templates
template close(s`gensym111: AsyncListener)
- Source Edit
template fd(s`gensym111: AsyncListener): SocketFD
- Source Edit
Exports
-
IP4, []=, ScopeId, isV4Mapped, IP6, flowId, IP4Endpoint, ==, port, port, IP6Endpoint, [], IP6Loopback, FlowId, ==, $, []=, len, $, $, ip, scopeId, initEndpoint, PortNone, IPEndpointKind, IP4Broadcast, ==, [], Port, ip, IP4Any, ip4, IPEndpoint, ip6, len, initEndpoint, IP6Any, $, IP4Loopback