读书人

Socket联接客户端(待续)

发布时间: 2012-07-01 13:15:00 作者: rapoo

Socket连接客户端(待续)

 if (null == socket)            {                socket = new Socket(Cache.getIp(), Cache.getPort());            }            dOut = new DataOutputStream(socket.getOutputStream());            in = new DataInputStream(socket.getInputStream());             String l = "WIG+001;2006071000000028;20060710094936;01:15960198075;02:15960061802";            byte[] sendMsg = new byte[Constant.LenType.LENXX + l.length()];            System.arraycopy(Tool.intToByte(l.length()), 0, sendMsg, 0,                    Constant.NumType.ITEM2);            System.arraycopy(l.getBytes(), 0, sendMsg, Constant.NumType.ITEM2,                    l.length());              dOut.write(sendMsg);            int len = in.readShort();                     byte[] readMsg = new byte[len];            in.read(readMsg);            String str = new String(readMsg);

读书人网 >开源软件

热点推荐