ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## client::closesocket ### 接口说明 >关闭客户端连接 > +++ put:closesocket <<< success 无返回值 +++ ### 代码演示 ~~~ #import "socket" var socket_connected() { println("连接成功啦"); var writer = new Buffer(); writer.writeString("这是一个乒乓消息"); client.send(writer); } var socket_data(var buffer) { var s = buffer.tostring(); println(s); Sleep(5000); var writer = new Buffer(); writer.writeString(buffer.tostring()); client.send(writer); } var socket_close(var err,var errstr) { println("检测到有一个关闭:err:{err},errstr:{errstr}"); } var client = new socket::client(); client.setoption(new ClientOption(){ connected = socket_connected, data = socket_data, close = socket_close }); var b = client.connect("192.168.1.166",4060); while (true) { client.run(); } ~~~