zlhkzjy 2019-12-05 19:09 采纳率: 0%
浏览 1038

Exception in thread "main" java.lang.Error:报错

运行后一直报错?
public class Demo {
private static UxServer server;
public static void testServer() throws IOException{
server = new UxServer().bind(new InetSocketAddress(8008)).listen(new UxSocketListener() {
@Override
public void onOpen(UxSocket socket) {
System.out.println("on-socket-open:"+socket.address());
try {
socket.sendData("https://www.biblegateway.com/passage/?search=Psalm+62%3A5-12&version=NLTCommon people are as worthless as a puff of wind,and the powerful are not what they appear to be.Don鈥檛 make your living by extortiondon鈥檛 make it the center of your life.God has spoken plainlyPower, O God, belongs to you".getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onData(UxSocket socket, byte[] data) {
System.out.println("on-socket-data:"+socket.address()+"->"+new String(data));
if(new String(data).startsWith("rp")){
try {
socket.sendData(data);
} catch (IOException e) {
e.printStackTrace();
}
}
for(UxSocket s: server.clients()){
try {
s.sendData(data);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@Override
public void onClose(UxSocket socket) {
System.out.println("on-socket-close:"+socket.address()+ socket.closeInfo());
}
});
System.out.println("server");
}
public static void testClient() throws IOException{
UxSocket socket = new UxSocket();
socket.listen(new UxSocketListener() {
@Override
public void onOpen(UxSocket socket) {
System.out.println("on-open");
try {
socket.sendData("hi123456".getBytes());
socket.sendData("woabc".getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onData(UxSocket socket, byte[] data) {
System.out.println("on-data:"+new String(data));
}
@Override
public void onClose(UxSocket socket) {
System.out.println("on-close-"+ socket.closeInfo());
}
})
.connect(new InetSocketAddress("127.0.0.1",8008));
// .connect(new InetSocketAddress("s1.gz.1251014155.clb.myqcloud.com", 8008));
try {
Thread.sleep(1000L);
for(int i=0;i<1000;i++){
socket.sendData(("rp-msgat:"+i).getBytes());
Thread.sleep(10L);
}
Thread.sleep(300000L);
System.exit(0);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
boolean serverAble = args.length==1 && args[0].equals("1");
if(args.length==0)serverAble=true;
if(serverAble){
testServer();
}else{
testClient();
}
}
}图片说明

  • 写回答

1条回答

  • 是希望 2019-12-06 07:19
    关注

    IOException
    要自己创建一个吧,或者直接用Exception(小白见解,大佬轻喷)

    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题