💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## server::closesocket ### 接口说明 >关闭指定客户端 > +++ put:closesocket var:socketindex=连接索引ID# <<< 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(); ~~~