nupp.io.net.spi

Implementation interface for network transports.

Importing this declaration opens no sockets. The facade retains the provider table and supplies it as the explicit receiver for every operation. Provider handles are opaque; shared Address values come from nupp.io.net.types.

Listener acceptance, connection completion, and stream I/O are readiness probes. They must not run a private blocking loop. run(timeoutMs) pumps the provider's reactor, and the public facade exposes pumping as nupp.io.net.pump. Keep handle ownership separate for listeners, connect requests, streams, and datagrams.

Pending and EOF conventions differ by operation and are documented below. Report failures through the declared error result rather than disguising them as pending work. A TLS provider wrapping these streams must understand their handle representation; selection cannot make unrelated transport handles interoperable.

Module contents

Types

TypeKindDescription
Providerinterface

Types#

Providerinterface#

interface Provider ...

Members

NameKindDescription
priorityfield
listenmethodCreates a TCP listener; returns its handle or nil and an error.
listenPathmethodCreates a local-path listener with the requested backlog.
listenerPortmethodReturns the bound port, or -1 when no IP port is available.
acceptmethodReturns an accepted stream, nil while pending, or nil and an error.
closeListenermethodReleases a listener and its pending accept resources.
connectmethodStarts a TCP connection request with a millisecond timeout.
connectPathmethodStarts a local-path connection request with a millisecond timeout.
connectPollmethodReturns the completed stream, nil while pending, or nil and an error.
closeConnectmethodReleases the connection request, independently of any resulting stream.
readmethodReturns up to wanted bytes; an empty string means no bytes are ready.
endedmethodReports that no further read bytes will arrive.
writemethodReturns the accepted byte count, or nil and an error.
pendingmethodReturns bytes accepted for writing that have not yet drained.
writeFailedmethodReports a terminal write failure, including one after enqueueing.
shuttingDownmethodReports that the sending half is shutting down.
shutdownWritemethodEnds the sending half after queued writes; reports success or an error.
addressmethodReturns the canonical peer or local Address, or nil when unavailable.
noDelaymethodSets TCP no-delay behavior on a stream.
keepAlivemethodConfigures TCP keepalive and its idle delay in milliseconds.
broadcastmethodEnables or disables sending broadcast datagrams.
multicastTtlmethodSets the datagram multicast hop limit.
multicastLoopmethodEnables or disables local multicast loopback.
membershipmethodJoins or leaves a multicast group on the named interface.
closeStreammethodReleases a stream and its queued native resources.
bindDatagrammethodCreates a bound datagram socket or returns nil and an error.
datagramPortmethodReturns the bound datagram port, or -1 when unavailable.
receivemethodReturns bytes, source host, source port, truncation flag, and optional error.
sendTomethodSends one datagram to the destination or reports an error.
closeDatagrammethodReleases a datagram socket.
runmethodPumps shared reactor readiness for at most timeoutMs milliseconds.

priorityfield#

priority: integer?
@readonly

listenmethod#

listen: function(self: Provider, host: string, port: integer, backlog: integer, reusePort: boolean): (any?, string?)
@readonly

Creates a TCP listener; returns its handle or nil and an error.

Arguments
NameTypeDescription
selfProvider
hoststring
portinteger
backloginteger
reusePortboolean
Returns
TypeDescription
any?
string?

listenPathmethod#

listenPath: function(self: Provider, path: string, backlog: integer): (any?, string?)
@readonly

Creates a local-path listener with the requested backlog.

Arguments
NameTypeDescription
selfProvider
pathstring
backloginteger
Returns
TypeDescription
any?
string?

listenerPortmethod#

listenerPort: function(self: Provider, listener: any): integer
@readonly

Returns the bound port, or -1 when no IP port is available.

Arguments
NameTypeDescription
selfProvider
listenerany
Returns
TypeDescription
integer

acceptmethod#

accept: function(self: Provider, listener: any): (any?, string?)
@readonly

Returns an accepted stream, nil while pending, or nil and an error.

Arguments
NameTypeDescription
selfProvider
listenerany
Returns
TypeDescription
any?
string?

closeListenermethod#

closeListener: function(self: Provider, listener: any): nil
@readonly

Releases a listener and its pending accept resources.

Arguments
NameTypeDescription
selfProvider
listenerany
Returns
TypeDescription
nil

connectmethod#

connect: function(self: Provider, host: string, port: integer, timeoutMs: integer): (any?, string?)
@readonly

Starts a TCP connection request with a millisecond timeout.

Arguments
NameTypeDescription
selfProvider
hoststring
portinteger
timeoutMsinteger
Returns
TypeDescription
any?
string?

connectPathmethod#

connectPath: function(self: Provider, path: string, timeoutMs: integer): (any?, string?)
@readonly

Starts a local-path connection request with a millisecond timeout.

Arguments
NameTypeDescription
selfProvider
pathstring
timeoutMsinteger
Returns
TypeDescription
any?
string?

connectPollmethod#

connectPoll: function(self: Provider, request: any): (any?, string?)
@readonly

Returns the completed stream, nil while pending, or nil and an error.

Arguments
NameTypeDescription
selfProvider
requestany
Returns
TypeDescription
any?
string?

closeConnectmethod#

closeConnect: function(self: Provider, request: any): nil
@readonly

Releases the connection request, independently of any resulting stream.

Arguments
NameTypeDescription
selfProvider
requestany
Returns
TypeDescription
nil

readmethod#

read: function(self: Provider, stream: any, wanted: integer): (string?, string?)
@readonly

Returns up to wanted bytes; an empty string means no bytes are ready. Use ended to distinguish EOF. nil with an error reports a failed read.

Arguments
NameTypeDescription
selfProvider
streamany
wantedinteger
Returns
TypeDescription
string?
string?

endedmethod#

ended: function(self: Provider, stream: any): boolean
@readonly

Reports that no further read bytes will arrive.

Arguments
NameTypeDescription
selfProvider
streamany
Returns
TypeDescription
boolean

writemethod#

write: function(self: Provider, stream: any, bytes: string): (integer?, string?)
@readonly

Returns the accepted byte count, or nil and an error. Accepted bytes may remain queued; pending reports their outstanding count.

Arguments
NameTypeDescription
selfProvider
streamany
bytesstring
Returns
TypeDescription
integer?
string?

pendingmethod#

pending: function(self: Provider, stream: any): integer
@readonly

Returns bytes accepted for writing that have not yet drained.

Arguments
NameTypeDescription
selfProvider
streamany
Returns
TypeDescription
integer

writeFailedmethod#

writeFailed: function(self: Provider, stream: any): boolean
@readonly

Reports a terminal write failure, including one after enqueueing.

Arguments
NameTypeDescription
selfProvider
streamany
Returns
TypeDescription
boolean

shuttingDownmethod#

shuttingDown: function(self: Provider, stream: any): boolean
@readonly

Reports that the sending half is shutting down.

Arguments
NameTypeDescription
selfProvider
streamany
Returns
TypeDescription
boolean

shutdownWritemethod#

shutdownWrite: function(self: Provider, stream: any): (boolean, string?)
@readonly

Ends the sending half after queued writes; reports success or an error.

Arguments
NameTypeDescription
selfProvider
streamany
Returns
TypeDescription
boolean
string?

addressmethod#

address: function(self: Provider, stream: any, peer: boolean): Address?
@readonly

Returns the canonical peer or local Address, or nil when unavailable.

Arguments
NameTypeDescription
selfProvider
streamany
peerboolean
Returns
TypeDescription
Address?

noDelaymethod#

noDelay: function(self: Provider, stream: any, enable: boolean): (boolean, string?)
@readonly

Sets TCP no-delay behavior on a stream.

Arguments
NameTypeDescription
selfProvider
streamany
enableboolean
Returns
TypeDescription
boolean
string?

keepAlivemethod#

keepAlive: function(self: Provider, stream: any, enable: boolean, delayMs: integer): (boolean, string?)
@readonly

Configures TCP keepalive and its idle delay in milliseconds.

Arguments
NameTypeDescription
selfProvider
streamany
enableboolean
delayMsinteger
Returns
TypeDescription
boolean
string?

broadcastmethod#

broadcast: function(self: Provider, socket: any, enable: boolean): (boolean, string?)
@readonly

Enables or disables sending broadcast datagrams.

Arguments
NameTypeDescription
selfProvider
socketany
enableboolean
Returns
TypeDescription
boolean
string?

multicastTtlmethod#

multicastTtl: function(self: Provider, socket: any, ttl: integer): (boolean, string?)
@readonly

Sets the datagram multicast hop limit.

Arguments
NameTypeDescription
selfProvider
socketany
ttlinteger
Returns
TypeDescription
boolean
string?

multicastLoopmethod#

multicastLoop: function(self: Provider, socket: any, enable: boolean): (boolean, string?)
@readonly

Enables or disables local multicast loopback.

Arguments
NameTypeDescription
selfProvider
socketany
enableboolean
Returns
TypeDescription
boolean
string?

membershipmethod#

membership: function(
    self: Provider,
    socket: any,
    group: string,
    interfaceAddress: string,
    join: boolean
): (boolean, string?)
@readonly

Joins or leaves a multicast group on the named interface. An empty interface address selects the host default.

Arguments
NameTypeDescription
selfProvider
socketany
groupstring
interfaceAddressstring
joinboolean
Returns
TypeDescription
boolean
string?

closeStreammethod#

closeStream: function(self: Provider, stream: any): nil
@readonly

Releases a stream and its queued native resources.

Arguments
NameTypeDescription
selfProvider
streamany
Returns
TypeDescription
nil

bindDatagrammethod#

bindDatagram: function(self: Provider, host: string, port: integer, reusePort: boolean): (any?, string?)
@readonly

Creates a bound datagram socket or returns nil and an error.

Arguments
NameTypeDescription
selfProvider
hoststring
portinteger
reusePortboolean
Returns
TypeDescription
any?
string?

datagramPortmethod#

datagramPort: function(self: Provider, socket: any): integer
@readonly

Returns the bound datagram port, or -1 when unavailable.

Arguments
NameTypeDescription
selfProvider
socketany
Returns
TypeDescription
integer

receivemethod#

receive: function(self: Provider, socket: any, maximum: integer): (string?, string?, integer?, boolean?, string?)
@readonly

Returns bytes, source host, source port, truncation flag, and optional error. A nil first result without an error means no datagram is ready.

Arguments
NameTypeDescription
selfProvider
socketany
maximuminteger
Returns
TypeDescription
string?
string?
integer?
boolean?
string?

sendTomethod#

sendTo: function(self: Provider, socket: any, host: string, port: integer, bytes: string): (boolean, string?)
@readonly

Sends one datagram to the destination or reports an error.

Arguments
NameTypeDescription
selfProvider
socketany
hoststring
portinteger
bytesstring
Returns
TypeDescription
boolean
string?

closeDatagrammethod#

closeDatagram: function(self: Provider, socket: any): nil
@readonly

Releases a datagram socket.

Arguments
NameTypeDescription
selfProvider
socketany
Returns
TypeDescription
nil

runmethod#

run: function(self: Provider, timeoutMs: integer): nil
@readonly

Pumps shared reactor readiness for at most timeoutMs milliseconds. A zero timeout performs a nonblocking pass.

Arguments
NameTypeDescription
selfProvider
timeoutMsinteger
Returns
TypeDescription
nil