`
bdk82924
  • 浏览: 555577 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

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);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics