import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=469)
winform.add(
button={cls="button";text="Button";left=128;top=104;right=272;bottom=144;z=1}
)
/*}}*/
import hpsocket.tcpServer;
var server = hpsocket.tcpServer();
server.start("192.168.1.143",6003);
server.onThreadCreated = function(){
/*监听线程首次回调前触发*/
}
server.onThreadEnd = function(){
/*监听线程退出前触发*/
}
server.onPrepareListen = function(hpTcpServer,soListen){
/*绑定监听地址前触发*/
}
server.onAccept = function(hpTcpServer,connId,pClient){
/*接受请求触发*/
}
server.onHandShake = function(hpTcpServer,connId,pClient){
/*握手完成触发*/
}
server.onSend = function(hpTcpServer,connId,pData,length){
var data = ..raw.tostring(pData,1,length)
/*数据发送成功后触发*/
}
server.onReceive = function(hpTcpServer,connId,pData,length){
var data = ..raw.tostring(pData,1,length)
/*接收到数据时触发*/
import console;
console.dump(connId,data)
}
server.onClose = function(hpTcpServer,connId,enOperation,errCode){
/*连接正常或异常关闭时触发*/
}
server.onShutdown = function(hpTcpServer){
/*关闭通信组件触发*/
}
winform.button.oncommand = function(id,event){
}
winform.show();
win.loopMessage();
import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=469)
winform.add(
button={cls="button";text="Button";left=112;top=72;right=224;bottom=112;z=1}
)
/*}}*/
import hpsocket.tcpClient;
var client = hpsocket.tcpClient()
client.start("192.168.1.143",6003,true);
client.onThreadCreated = function(){
/*监听线程首次回调前触发*/
import console;
..console.log("连接成功")
}
client.onThreadEnd = function(){
/*监听线程退出前触发*/
import console;
..console.log("连接成功")
}
client.onPrepareConnect = function(hpTcpClient,connId,soListen){
/*准备建立连接前触发*/
import console;
..console.log("连接成功")
}
client.onHandShake = function(hpTcpClient,connId){
/*握手完成触发*/
import console;
..console.log("连接成功")
}
client.onSend = function(hpTcpClient,connId,pData,length){
var data = ..raw.tostring(pData,1,length)
/*数据发送成功后触发*/
}
client.onConnect = function(hpTcpClient,connId){
/*建立连接后触发*/
}
client.onReceive = function(hpTcpClient,connId,pData,length){
var data = ..raw.tostring(pData,1,length)
import console;
..console.dump(data)
/*接收到数据时触发*/
}
client.onClose = function(hpTcpClient,connId,enOperation,errCode){
/*连接正常或异常关闭时触发*/
}
client.onShutdown = function(hpTcpClient){
/*关闭通信组件触发*/
}
winform.button.oncommand = function(id,event){
client.send(raw.buffer("123"))
}
winform.show();
win.loopMessage();