现编这个就是个多线程服务器,只要在client不释放连接,服务器端的run里边写while(TRUE)循环,那么就可以长期连接。class ConnectionThread extends Thread{Socket client;int counter;public ConnectionThread(Socket cl,int c){client = cl;counter= c;} @OverridEpublic void run(){ try{ String destIP=client.getInetAddress().toString()

转字节流或字节流转字符串发送和接收端都指定为utf8,长度应该是没有限制的,你可以不指定长度读取,一个个的输出看看结果。实在不行,可以自己分包,多少字符串分成一个包,设置结束符,再组合起来。最好定义下检验。