socket

ModuleServer-Side

TCP socket interface

Documentation

socketconnectoptionsConnectOptionscallbackerrorstringfalsesocketClientSocketfalseundefineddataArrayBufferlistenoptionsListenOptionsacceptClientSocketundefineddataArrayBuffercallbackerrorstringfalsesocketServerSocketfalse

TCP client/server. callback receives either an error string or socket instance. accept is executed with every accepted connection. Data is received on a ClientSocket object by setting its onReceive listener or returning the listener from connect's callback or listen's accept functions. onError and onDisconnect listeners can be set on ClientSocket and ServerSocket objects.

ConnectOptionsaddress'127.0.0.1'stringportnumbernameundefinedstring
ListenOptionsaddress'0.0.0.0'stringportnumberbacklog50numbernameundefinedstring
ClientSocketsenddataArrayBuffercallbackinfoSendInfodisconnectfunctionsetPausedpausedbooleancallbackerrorstringfalsesetKeepAliveenabledbooleandelaynumbercallbackerrorstringfalsesetNoDelayenabledbooleancallbackerrorstringfalsegetInfocallbackClientSocketInfosocketIdnumberonReceivedataArrayBufferonErrorerrornumberonDisconnectfunction

setKeepAlive accepts a delay in seconds since the socket's last transmission.

SendInforesultCodenumbererrorstringundefinedbytesSentnumberundefined
ClientSocketInfosocketIdnumbernamestringundefinedconnectedbooleanlocalAddressstringlocalPortnumberpeerAddressstringpeerPortnumber
ServerSocketdisconnectfunctiongetInfocallbackServerSocketInfosocketIdnumberonErrorerrornumberonDisconnectfunction
ServerSocketInfosocketIdnumbernamestringundefinedpeerAddressstringpeerPortnumber