Sockets are used for duplex raw data transfer using either named pipes (Windows) or TCP/IP sockets between two Sciter processes running either on the same machine ("localhost" address) or over the wire. Socket supports server listening sockets (Socket.listen() ) and client sockets (Socket.connect()) .
Socket sends/receive raw data - strings or bytes. You send data by socket.send(data) and receive them by socket.on("receive", function(data) {}) on other end.
( port: integer [, domain: string] ) : DataSocket
Constructs client DataSocket. Returns new socket in connecting state.
( acceptor: function, port: integer [, domain: string] ) : DataSocket
Constructs server DataSocket. Returns new socket in listening state.
The acceptor function is being called on each new connection request to the server. It has following signature:
function acceptor( connectionSocket: DataSocket ) : true | false
where connectionSocket is another instance of DataSocket used for communication with remote peer.
You MUST return true from the acceptor in order to accept and use the connection.
( event: string, callback: function ) : this
Subscribes the callback to one of socket events:
function(), socket just connected to the host;function(data:string), the data has been received;function(), data were sent in full;function(err: Error), error occured, error object passed to the function;function(), socket was closed;The event name may contain ".namespace" part that can be used in .off() call.
( event: string | callback: function ) : this
Unsubscribe callback either by its name or by its function reference.
Event name may contain only namespace part, so this: socket.off(".namespace") will unsubscribe all handlers that were set with that namespace.
( data: any )
The method sends data to the peer. The data can be any serializeable data type (object, number, string, array, etc.).
( )
Closes the socket.