8. Network socket library
The NETWORK module implements basic TCP socket listening server (currently only one connection). It would eventually be expanded to support client as well.
It its present form its used in Daslang Visual Studio Code plugin and upcoming debug server.
All functions and symbols are in “network” module, use require to get access to it.
require network
8.2. Classes
- Server
- Fields
_server : smart_ptr< NetworkServer > - Single socket listener combined with single socket connection.
- Server.make_server_adapter()
Creates a server adapter for the given server instance.
- Server.init(port: int) : bool()
Returns true if the server was successfully initialized on the given port.
- Arguments
port : int
- Server.restore(shared_orphan: smart_ptr<NetworkServer>&)
Restores the server with the given shared orphan network server pointer. This is necessary to re-establish the server state after reload of a script.
- Arguments
shared_orphan : smart_ptr< NetworkServer >&
- Server.save(shared_orphan: smart_ptr<NetworkServer>&)
Saves the server state to a shared orphan network server pointer. This is necessary to re-establish the server state after reload of a script.
- Arguments
shared_orphan : smart_ptr< NetworkServer >&
- Server.has_session() : bool()
Returns true if the server has an active session.
- Server.is_open() : bool()
Return true if the server is open and ready to accept connections.
- Server.is_connected() : bool()
Returns true if the server is connected to a client.
- Server.tick()
Ticks the server to process incoming connections and data.
- Server.send(data: uint8?; size: int) : bool()
Sends data to the connected client. Returns true if the data was sent successfully.
- Arguments
data : uint8?
size : int
- Server() : Server()
Initializes and returns a new instance of the network Server class.
8.3. Low lever NetworkServer IO
make_server (class: void? implicit; info: StructInfo const? implicit) : bool
server_init (server: smart_ptr<NetworkServer> implicit; port: int) : bool
server_is_open (server: smart_ptr<NetworkServer> implicit) : bool
server_is_connected (server: smart_ptr<NetworkServer> implicit) : bool
server_send (server: smart_ptr<NetworkServer> implicit; data: uint8? implicit; size: int) : bool
- make_server(class: void? implicit; info: StructInfo const? implicit) : bool()
Creates new instance of the server.
- Arguments
class : void? implicit
info : StructInfo ? implicit
- server_init(server: smart_ptr<NetworkServer> implicit; port: int) : bool()
Initializes server with given port.
- Arguments
server : smart_ptr< NetworkServer > implicit
port : int
- server_is_open(server: smart_ptr<NetworkServer> implicit) : bool()
Returns true if server is listening to the port.
- Arguments
server : smart_ptr< NetworkServer > implicit
- server_is_connected(server: smart_ptr<NetworkServer> implicit) : bool()
Returns true if server is connected to the client.
- Arguments
server : smart_ptr< NetworkServer > implicit
- server_tick(server: smart_ptr<NetworkServer> implicit)
This needs to be called periodically for the server to work.
- Arguments
server : smart_ptr< NetworkServer > implicit
- server_send(server: smart_ptr<NetworkServer> implicit; data: uint8? implicit; size: int) : bool()
Sends data from server to the client.
- Arguments
server : smart_ptr< NetworkServer > implicit
data : uint8? implicit
size : int
- server_restore(server: smart_ptr<NetworkServer> implicit; class: void? implicit; info: StructInfo const? implicit)
Restores server from orphaned state.
- Arguments
server : smart_ptr< NetworkServer > implicit
class : void? implicit
info : StructInfo ? implicit