代码package com.linkage.netmsg.server;import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import com.linkage.netmsg.NetMsgclient;public class IM {
static OutputStream out; static InputStream in = null;
public static boolean result;
public static void main(String[] args) throws IOException{
NetMsgclient client = new NetMsgclient();
ReceiveMsg receiveMsg = new Receive();
client = client.initParameters("218.94.58.243", 9005, "username", "password",receiveMsg);
try {
boolean isLogin = client.anthenMsg(client);
if(isLogin)System.out.println("login sucess");
for(int i =0 ; i < 30;i++)
{
client.sendMsg(client, 0, "165616161", "test", 1);
}
client.closeConn();
} catch (Exception e1) {
e1.printStackTrace();
}
System.out.println(result); }}显示效果
连接异常,尝试重新连接java.lang.NullPointerException
at com.linkage.netmsg.NetMsgclient.send(NetMsgclient.java:976)
at com.linkage.netmsg.NetMsgclient.recordCommon(NetMsgclient.java:575)
at com.linkage.netmsg.NetMsgclient.sendMsg(NetMsgclient.java:792)
at com.linkage.netmsg.server.IM.main(IM.java:41)false
重新连接成功
网络异常,重新自动登录失败
连接异常,尝试重新连接
重新连接成功
网络异常,重新自动登录失败
连接异常,尝试重新连接
重新连接成功
网络异常,重新自动登录失败
连接异常,尝试重新连接
重新连接成功
网络异常,重新自动登录失败
连接异常,尝试重新连接
重新连接成功
import java.io.InputStream;
import java.io.OutputStream;
import com.linkage.netmsg.NetMsgclient;public class IM {
static OutputStream out; static InputStream in = null;
public static boolean result;
public static void main(String[] args) throws IOException{
NetMsgclient client = new NetMsgclient();
ReceiveMsg receiveMsg = new Receive();
client = client.initParameters("218.94.58.243", 9005, "username", "password",receiveMsg);
try {
boolean isLogin = client.anthenMsg(client);
if(isLogin)System.out.println("login sucess");
for(int i =0 ; i < 30;i++)
{
client.sendMsg(client, 0, "165616161", "test", 1);
}
client.closeConn();
} catch (Exception e1) {
e1.printStackTrace();
}
System.out.println(result); }}显示效果
连接异常,尝试重新连接java.lang.NullPointerException
at com.linkage.netmsg.NetMsgclient.send(NetMsgclient.java:976)
at com.linkage.netmsg.NetMsgclient.recordCommon(NetMsgclient.java:575)
at com.linkage.netmsg.NetMsgclient.sendMsg(NetMsgclient.java:792)
at com.linkage.netmsg.server.IM.main(IM.java:41)false
重新连接成功
网络异常,重新自动登录失败
连接异常,尝试重新连接
重新连接成功
网络异常,重新自动登录失败
连接异常,尝试重新连接
重新连接成功
网络异常,重新自动登录失败
连接异常,尝试重新连接
重新连接成功
网络异常,重新自动登录失败
连接异常,尝试重新连接
重新连接成功
不知道哪错了