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个回答

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐