| 发表于:2007-01-22 10:20:51 楼主 |
服务器端send public static void send(socket s,string data){ printwriter output; //输出流 try{ dataoutputstream out = new dataoutputstream(s.getoutputstream)); byte[] b = data.getbytes(); output = new printwriter(out,true); output.print(b); output.flush(); system.out.println(data); }catch(exception e){} } 客户端receive socket socket = new socket( "127.0.0.1 ", 9000); datainputstream datain = new datainputstream(socket.getinputstream()); byte[] b = new byte[socket.getinputstream().available()]; string strrecv = " "; while (datain.read(b) != 0) { strrecv = new string(b, "gb2312 "); system.out.println(strrecv); } out.close(); dataout.close(); datain.close(); 服务器端的接收也是和客户端接收一样的写法,发送也是. 服务器端可以接收到数据,可客户端就接收不到. 找不到问题所在,求大家帮忙! |
|
|
|
|