多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## client::connect ### 接口说明 >客户端连接 > +++ put:connect var:addres=连接地址# var:port=端口# <<< 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(); } ~~~