Skip to content

net.sockets

Peter edited this page Mar 19, 2024 · 5 revisions

v1.8

_G.net.sockets

Overview

Functions

Signature Return Description
socketExists(name) boolean Returns if a socket with name exists
makeSocket(name, remote, port) NetSocket Make a new named socket. CLOSES SOCKET IF ONE EXISTS
getOrMakeSocket(name, remote, port) NetSocket Gets named socket, or creates one if not present, returning the socket
getSocket(name) NetSocket? Gets named socket
closeSocket(name) nil Closes the named socket and removes it
listSockets() string[] Get a list of the names of all tracked sockets
NetSocket(remote, port?) NetSocket

Variables

Variable Description
[NetSocketType: string] Message type for net sockets: socket

Classes

NetSocket

Detail

Functions

socketExists

net.sockets.socketExists(name: string): boolean

Returns if a socket with name exists

Parameters

  • name: string - Socket name

Returns

  • exists: boolean

makeSocket

net.sockets.makeSocket(name: string, remote: string|NetAddress, port: number): NetSocket

Make a new named socket. CLOSES SOCKET IF ONE EXISTS

Parameters

  • name: string - Socket name
  • remote: string|NetAddress - Socket remote address (hostname, IP or HW)
  • port: number - Socket port

Returns

  • socket: NetSocket

getOrMakeSocket

net.sockets.getOrMakeSocket(name: string, remote: string|NetAddress, port: number): NetSocket

Gets named socket, or creates one if not present, returning the socket

Parameters

  • name: string - Socket name
  • remote: string|NetAddress - Socket remote address (hostname, IP or HW)
  • port: number - Socket port

Returns

  • socket: NetSocket

getSocket

net.sockets.getSocket(name: string): NetSocket?

Gets named socket

Parameters

  • name: string - Socket name

Returns

  • socket: NetSocket?

closeSocket

net.sockets.closeSocket(name: string): nil

Closes the named socket and removes it

Parameters

  • name: string - Socket name

listSockets

net.sockets.listSockets(): string[]

Get a list of the names of all tracked sockets

Returns

  • socketNames: string[]
Clone this wiki locally