1

Please give me some examples (code on both languages) on how to send float array from c# to Java via socket. Thanks.

1
  • 5
    Alex, this is not how it works here. You don't just ask for code. You show what you did, explain where you hit a problem, and ask for for help. The question how it's worded now is begging the RTFM answer. Commented Apr 14, 2011 at 12:11

4 Answers 4

2

I believe you can serialize this array as string [1.25,1.4556,1.34545] and then read this string in Java and de-serialize to array.

I don't like SOAP :)

Sign up to request clarification or add additional context in comments.

Comments

1

You cannot directly send them since the two float[] are not interoperable. You have to go for a standard protocol to share them. SOAP could be one of them.

1 Comment

Why aren't they interoperable? They should both be in IEEE format.
1

Text is likely to be the safest way to pass the data. However you can readFloat() using DataInput or via ByteBuffers. There must be a similar option in C#.

Comments

1

You somehow have to convert your floats on one side to bytes, write them to the output-stream of the socket, read them from the input-stream of the socket, and convert those back to floats.

There is the IEEE 754 standard which defines a bit layout - in Java this is implemented by Float.floatToIntBits and Float.intBitsToFloat, and also by the readFloat/writeFloat methods of DataInputStream.

I suppose there will be a similar method on the .NET side, but I don't know anything about this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.