give you a good solutionyou could search google.com for ASN.1,this is a technique for solveing different language using socket to make communication

解决方案 »

  1.   

    不懂
    up
    DavidBone(7级宝宝)的solution要money
      

  2.   

    please use byte array. firstly get the content as byte[] via socket inputstream,
    then parse your byte array. for example, if you want to convert a 32bit long(in c)
    to long(in java), please use the following code://let offset to corrent positionlong tmpLong += ((int)line[offset] & 0x00FF);
    tmpLong += ((int)line[offset+1] & 0x00FF) << 8;
    tmpLong += ((int)line[offset+2] & 0x00FF) << 16;
    tmpLong = ((int)line[offset+3] & 0x00FF) << 24;
      

  3.   

    asn.1 OR XML
    for general data strcuture representation.
      

  4.   

    对于结构体在Socket中传递,一般的都是以0x00结束,可以以Byte的形式接受,
    但是遇到汉字就比较麻烦了,
    而字段间是顺序存放的,所以可以顺序方式来存取。
    但是java的byte是双字节的
      

  5.   

    先转成byte数组,java程序接收到后再做转换。只要了解数据的结构转换应该不是很困难阿。
      

  6.   

    以前做过,好象是用char[],其他可能会有问题,尤其是在char的值大于127的时候,不知道为什么转到c里之后,就会变成两位或者三位,
      

  7.   

    http://www-900.ibm.com/developerWorks/cn/education/java/j-jni/tutorial/index.html
      

  8.   

    呵呵,前一段我也在做这个,java里边没有结构,而且数据在内存存放方式也与c不同,郁闷啊,只有手动的转换数据,真是累。
      

  9.   

    to elabs(洋洋) 能否把你的代码让我看看
    谢谢
    [email protected]
      

  10.   

    我对这个方面的问题没有做过,
    但是我的思路是:
        1。将你的数据结构(你的struct) 写成xml形式,然后用java来解析它。
        2. 这种方法还要土,我不知道你有没有看thinkinjava中的那“垃圾收集器”程序,它里面就是用一个类自动装载的方法来解决了问题。你可以自己先事先写好用来接收C的几个类,然后在接收时动态的装入这些类。供你参考