问题如下:我建立一个socket.连接一个主机IP和端口.
代码如下:
public void checkUserByNc(String ip, int port) throws
        IOException {
        Socket sentRequest;
        try {
            sentRequest = new Socket(ip, port); //创建套接字
            DataOutputStream outData = new DataOutputStream(out); 
            String strHead = "$$MessageStart$$";
            byte version = 1; //协议版本号
            int serial = 0; //序列号
            short type = 1; //类型
            short sub_type = 1; //子类型
            int len = 36; //消息体长度
            String username = "liuyubo";
            String password = "123456";            outData.write(strHead.getBytes());
            outData.writeByte(version);
            outData.writeInt(serial);
            outData.writeShort(type);
            outData.writeShort(sub_type);
            outData.writeInt(len);
            outData.write(username.getBytes());
            outData.write(password.getBytes());
            outData.close();
        }
        catch (Exception ex) {
            ex.printStackTrace();
            System.out.print("连接失败!!");
        }
    }
我想向这个机器的一个端口发送二进制数据.
我能不能一次性把所有要的数据给写出去,而不是像这样.根据类型不同.调用的不同的方法??