<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>lizongbo at 618119.com &#187; struct</title>
	<atom:link href="http://618119.com/tag/struct/feed" rel="self" type="application/rss+xml" />
	<link>http://618119.com</link>
	<description>工作,生活,java,apache,tomcat,Resin,mina,Hessian,Openfire,XMPP,RPC,Ubuntu</description>
	<lastBuildDate>Sat, 21 Aug 2010 08:34:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>关于java客户端与c写的服务器通信时的整数字节存放顺序</title>
		<link>http://618119.com/archives/2007/10/27/18.html</link>
		<comments>http://618119.com/archives/2007/10/27/18.html#comments</comments>
		<pubDate>Sat, 27 Oct 2007 13:07:57 +0000</pubDate>
		<dc:creator>lizongbo</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[byte2int]]></category>
		<category><![CDATA[C，int2byte]]></category>
		<category><![CDATA[struct]]></category>

		<guid isPermaLink="false">http://618119.com/archives/2007/10/27/18.html</guid>
		<description><![CDATA[C语言里通常可能开发人员直接定义struct 作为数据包,
因此在java客户端接收struct 中的数据时候,受整数等类型的高低位存放的影响,
需要进行相应的转换,
参考:
http://www.ibm.com/developerworks/cn/java/l-datanet/index.html

转换代码如下:
package com.lizongbo.util;
/**
*
* &#60;p&#62;Title: 数字转换工具类&#60;/p&#62;
*
* &#60;p&#62;Description: 将数字类型与byte数组互相转换&#60;/p&#62;
*
* &#60;p&#62;Copyright: Copyright (c) 2007&#60;/p&#62;
*
* &#60;p&#62;Company: 618119.com&#60;/p&#62;
*
* @author lizongbo
* @version 1.0
*/
public class NumberUtil {
/**
* 整数转C++存放格式的字节数组
* @param v int
* @return byte[]
*/
public static byte[] int2Byte4C(int v) {
byte[] b = new byte[4];
//注意,不是java中的顺序的 b[0],b[1],b[2],b[3]
b[3] = (byte) ( (v &#62;&#62;&#62; 24) &#38; 0xFF);
b[2] = (byte) ( (v &#62;&#62;&#62; 16) &#38; 0xFF);
b[1] = (byte) [...]]]></description>
		<wfw:commentRss>http://618119.com/archives/2007/10/27/18.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
