企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## server::stop ### 接口说明 >服务端停止服务.断开所有连接 > +++ put:stop <<< success 无返回值 +++ ### 代码演示 ~~~ #import "socket" var socket_accept(var socketIndex) { println("检测到有一个连接:"..socketIndex); } var socket_data(var socketIndex,var buffer) { var s = buffer.tostring(); println(s); if(s == "e") { srv.closesocket(socketIndex); } var writer = new Buffer(); writer.writeString(buffer.tostring()); srv.send(socketIndex, writer); } var socket_close(var socketIndex,var err,var errstr) { println("检测到有一个关闭:{socketIndex},err:{err},errstr:{errstr}"); } var socket_parser(var headerbuffer) { var packagesize = headerbuffer.readInt32(); return packagesize; // 根据包头协议包大小 } println("start server"); var srv = new socket::server().setoption(new ServerOption(){ ip = "0.0.0.0", accept = socket_accept, data = socket_data, close = socket_close }).listen(4060); //使用带协议头方式 // var srv = new socket::server().setOption(new ServerOption(){ // ip = "0.0.0.0", // headersize = 4,//字节 // accept = socket_accept, // data = socket_data, // close = socket_close, // parser = socket_parser // }).listen(4060); println("start over"); while (true) srv.run(); srv.stop(); ~~~