整个包的定义包括
head 2byte
length
crc16 校验
flag
content 内容
end我对网络编程这块没接触过,希望大家指点下资料或者代码看看,有人讲解下java里发送和接受数据包的一些关键点,非常感谢
有资料最好
head 2byte
length
crc16 校验
flag
content 内容
end我对网络编程这块没接触过,希望大家指点下资料或者代码看看,有人讲解下java里发送和接受数据包的一些关键点,非常感谢
有资料最好
解决方案 »
- 类型判断
- 请问一下大家这段代码由上面问题?为什么会报错?
- 为什么java里面inner对象要访问的outer对象必须是final的啊
- 怎样在调试时可以看到jdk类中的方法中的局部变量的值?
- 有谁知道JCREATOR里为什么在编译applet文件时,能编译通过,可一运行就提示:没有main函数呀!
- 奇怪的问题,难道是传说中的Borland公司久未透露的JBuilder里的BUG?
- 我受不了Java了,
- 关于Properties类的问题
- 如何在DIALOG上画出一个有一定宽度的绿色的向下的箭头呢?
- 多重为空判断怎么写才好?
- 分别在命令行和eclipse运行java程序,有什么区别??
- java 传递的参数为对象引用类型~~ 求解释
InputStream bis = socket.getInputStream();
byte[] lengthBytes = new byte[4];
if (bis.read(lengthBytes, 0, 4) == 4) {
int length = Util.bytesToint(lengthBytes);
int rest = length;
byte[] messageBytes = new byte[length];
int read = 0;
while (rest > 0) {
byte[] buffer = new byte[rest];
read = bis.read(buffer);
if(read > length || rest < 0){
throw new ReadXmlBytesException("读取xml字节流溢出");
}
else {
System.arraycopy(buffer, 0, messageBytes, length - rest, read);
rest -= read;
}
}
return messageBytes;
} else {
throw new ReadXmlBytesException("获取数据长度失败");
}
}
public int src_port;
/** Destination port number */
public int dst_port;
/** Sequence number */
public long sequence;
/** ACK number */
public long ack_num;
/** URG flag */
public boolean urg;
/** ACK flag */
public boolean ack;
/** PSH flag */
public boolean psh;
/** RST flag */
public boolean rst;
/** SYN flag */
public boolean syn;
/** FIN flag */
public boolean fin;