.. _stdlib_network: ====================== 网络套接字库 ====================== .. include:: detail/network.rst NETWORK 模块实现了基本的 TCP 套接字监听服务器(目前只有一个连接)。 它最终也将扩展到支持客户端。 其目前的形式用于 Daslang Visual Studio Code 插件和即将推出的调试服务器。 所有函数和符号都在 “network ”模块中,使用 require 可以访问该模块。 :: require network ++++++++++++++++++ 处理结构 ++++++++++++++++++ .. _handle-network-NetworkServer: .. das:attribute:: NetworkServer |structure_annotation-network-NetworkServer| +++++++ 类 +++++++ .. _struct-network-Server: .. das:attribute:: Server |class-network-Server| 它的定义如下 | _server : smart_ptr< :ref:`network::NetworkServer ` > .. das:function:: Server.make_server_adapter(self: Server) |method-network-Server.make_server_adapter| .. das:function:: Server.init(self: Server; port: int const) init returns bool +--------+------------------------------------------------+ +argument+argument type + +========+================================================+ +self + :ref:`network::Server ` + +--------+------------------------------------------------+ +port +int const + +--------+------------------------------------------------+ |method-network-Server.init| .. das:function:: Server.restore(self: Server; shared_orphan: smart_ptr&) +-------------+--------------------------------------------------------------------------+ +argument +argument type + +=============+==========================================================================+ +self + :ref:`network::Server ` + +-------------+--------------------------------------------------------------------------+ +shared_orphan+smart_ptr< :ref:`network::NetworkServer ` >&+ +-------------+--------------------------------------------------------------------------+ |method-network-Server.restore| .. das:function:: Server.save(self: Server; shared_orphan: smart_ptr&) +-------------+--------------------------------------------------------------------------+ +argument +argument type + +=============+==========================================================================+ +self + :ref:`network::Server ` + +-------------+--------------------------------------------------------------------------+ +shared_orphan+smart_ptr< :ref:`network::NetworkServer ` >&+ +-------------+--------------------------------------------------------------------------+ |method-network-Server.save| .. das:function:: Server.has_session(self: Server) has_session returns bool |method-network-Server.has_session| .. das:function:: Server.is_open(self: Server) is_open returns bool |method-network-Server.is_open| .. das:function:: Server.is_connected(self: Server) is_connected returns bool |method-network-Server.is_connected| .. das:function:: Server.tick(self: Server) |method-network-Server.tick| .. das:function:: Server.send(self: Server; data: uint8? const; size: int const) send returns bool +--------+------------------------------------------------+ +argument+argument type + +========+================================================+ +self + :ref:`network::Server ` + +--------+------------------------------------------------+ +data +uint8? const + +--------+------------------------------------------------+ +size +int const + +--------+------------------------------------------------+ |method-network-Server.send| .. das:function:: Server.onConnect(self: Server) |method-network-Server.onConnect| .. das:function:: Server.onDisconnect(self: Server) |method-network-Server.onDisconnect| .. das:function:: Server.onData(self: Server; buf: uint8? const; size: int const) +--------+------------------------------------------------+ +argument+argument type + +========+================================================+ +self + :ref:`network::Server ` + +--------+------------------------------------------------+ +buf +uint8? const + +--------+------------------------------------------------+ +size +int const + +--------+------------------------------------------------+ |method-network-Server.onData| .. das:function:: Server.onError(self: Server; msg: string const; code: int const) +--------+------------------------------------------------+ +argument+argument type + +========+================================================+ +self + :ref:`network::Server ` + +--------+------------------------------------------------+ +msg +string const + +--------+------------------------------------------------+ +code +int const + +--------+------------------------------------------------+ |method-network-Server.onError| .. das:function:: Server.onLog(self: Server; msg: string const) +--------+------------------------------------------------+ +argument+argument type + +========+================================================+ +self + :ref:`network::Server ` + +--------+------------------------------------------------+ +msg +string const + +--------+------------------------------------------------+ |method-network-Server.onLog| ++++++++++++++++++++++++++ Low lever NetworkServer IO ++++++++++++++++++++++++++ * :ref:`make_server (class:void? const implicit;info:rtti::StructInfo const? const implicit;context:__context const) : bool ` * :ref:`server_init (server:smart_ptr\ const implicit;port:int const;context:__context const;at:__lineInfo const) : bool ` * :ref:`server_is_open (server:smart_ptr\ const implicit;context:__context const;at:__lineInfo const) : bool ` * :ref:`server_is_connected (server:smart_ptr\ const implicit;context:__context const;at:__lineInfo const) : bool ` * :ref:`server_tick (server:smart_ptr\ const implicit;context:__context const;at:__lineInfo const) : void ` * :ref:`server_send (server:smart_ptr\ const implicit;data:uint8? const implicit;size:int const;context:__context const;at:__lineInfo const) : bool ` * :ref:`server_restore (server:smart_ptr\ const implicit;class:void? const implicit;info:rtti::StructInfo const? const implicit;context:__context const;at:__lineInfo const) : void ` .. _function-_at_network_c__c_make_server_CI_qm__CI1_ls_CH_ls_rtti_c__c_StructInfo_gr__gr__qm__C_c: .. das:function:: make_server(class: void? const implicit; info: StructInfo const? const implicit) make_server returns bool +--------+------------------------------------------------------------------------+ +argument+argument type + +========+========================================================================+ +class +void? const implicit + +--------+------------------------------------------------------------------------+ +info + :ref:`rtti::StructInfo ` const? const implicit+ +--------+------------------------------------------------------------------------+ |function-network-make_server| .. _function-_at_network_c__c_server_init_CI1_ls_H_ls_network_c__c_NetworkServer_gr__gr__qm_M_Ci_C_c_C_l: .. das:function:: server_init(server: smart_ptr const implicit; port: int const) server_init returns bool +--------+----------------------------------------------------------------------------------------+ +argument+argument type + +========+========================================================================================+ +server +smart_ptr< :ref:`network::NetworkServer ` > const implicit+ +--------+----------------------------------------------------------------------------------------+ +port +int const + +--------+----------------------------------------------------------------------------------------+ |function-network-server_init| .. _function-_at_network_c__c_server_is_open_CI1_ls_H_ls_network_c__c_NetworkServer_gr__gr__qm_M_C_c_C_l: .. das:function:: server_is_open(server: smart_ptr const implicit) server_is_open returns bool +--------+----------------------------------------------------------------------------------------+ +argument+argument type + +========+========================================================================================+ +server +smart_ptr< :ref:`network::NetworkServer ` > const implicit+ +--------+----------------------------------------------------------------------------------------+ |function-network-server_is_open| .. _function-_at_network_c__c_server_is_connected_CI1_ls_H_ls_network_c__c_NetworkServer_gr__gr__qm_M_C_c_C_l: .. das:function:: server_is_connected(server: smart_ptr const implicit) server_is_connected returns bool +--------+----------------------------------------------------------------------------------------+ +argument+argument type + +========+========================================================================================+ +server +smart_ptr< :ref:`network::NetworkServer ` > const implicit+ +--------+----------------------------------------------------------------------------------------+ |function-network-server_is_connected| .. _function-_at_network_c__c_server_tick_CI1_ls_H_ls_network_c__c_NetworkServer_gr__gr__qm_M_C_c_C_l: .. das:function:: server_tick(server: smart_ptr const implicit) +--------+----------------------------------------------------------------------------------------+ +argument+argument type + +========+========================================================================================+ +server +smart_ptr< :ref:`network::NetworkServer ` > const implicit+ +--------+----------------------------------------------------------------------------------------+ |function-network-server_tick| .. _function-_at_network_c__c_server_send_CI1_ls_H_ls_network_c__c_NetworkServer_gr__gr__qm_M_CI1_ls_u8_gr__qm__Ci_C_c_C_l: .. das:function:: server_send(server: smart_ptr const implicit; data: uint8? const implicit; size: int const) server_send returns bool +--------+----------------------------------------------------------------------------------------+ +argument+argument type + +========+========================================================================================+ +server +smart_ptr< :ref:`network::NetworkServer ` > const implicit+ +--------+----------------------------------------------------------------------------------------+ +data +uint8? const implicit + +--------+----------------------------------------------------------------------------------------+ +size +int const + +--------+----------------------------------------------------------------------------------------+ |function-network-server_send| .. _function-_at_network_c__c_server_restore_CI1_ls_H_ls_network_c__c_NetworkServer_gr__gr__qm_M_CI_qm__CI1_ls_CH_ls_rtti_c__c_StructInfo_gr__gr__qm__C_c_C_l: .. das:function:: server_restore(server: smart_ptr const implicit; class: void? const implicit; info: StructInfo const? const implicit) +--------+----------------------------------------------------------------------------------------+ +argument+argument type + +========+========================================================================================+ +server +smart_ptr< :ref:`network::NetworkServer ` > const implicit+ +--------+----------------------------------------------------------------------------------------+ +class +void? const implicit + +--------+----------------------------------------------------------------------------------------+ +info + :ref:`rtti::StructInfo ` const? const implicit + +--------+----------------------------------------------------------------------------------------+ |function-network-server_restore|