当前位置: 首页 > 工具软件 > phoenixframe > 使用案例 >

socket客户端接收不到服务器消息 telent却接收得到,phoenixframe平台连接socket服务器,并接收返回值的示例...

翟黎明
2023-12-01

package org.phoenix.cases.plugin;

import java.util.LinkedList;

import org.phoenix.model.CaseLogBean;

import org.phoenix.model.UnitLogBean;

import org.phoenix.plugins.ITelnetClient;

import org.phoenix.proxy.ActionProxy;

/**

* Telnet客户端测试

* @author mengfeiyang

*

*/

public class TelnetPluginTest extends ActionProxy{

@Override

public LinkedList run(CaseLogBean caseLogBean) {

init(caseLogBean);

//连接SocketServer

ITelnetClient telnet = phoenix.telnetClient().configTelnetClient("localhost", 8889);

String rs = telnet.sendCommand("!showorders", "datas");//向socketServer发送指令,如果返回值以datas结尾,则终止数据接收

System.out.println(rs);

phoenix.checkPoint().checkIsNull(rs);

String rs2 = telnet.sendCommand("!showusers", "]");

System.out.println(rs2);

phoenix.checkPoint().checkIsNull(rs2);

telnet.disconnect();//断开本次的连接

return getUnitLog();

}

public static void main(String[] args) {

TelnetPluginTest p = new TelnetPluginTest();

LinkedList ll = p.run(new CaseLogBean());

for(UnitLogBean l : ll){

System.out.println(l.getContent());

}

}

}

 类似资料: