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);