Originally posted by Stan James:
I don't know C so I'm guessing at how to diagnose this.
* Is the size the same? 4-bytes on both sides?
* Is the order the same? See this Endian Essay for what I mean.
In any case, I'd read one byte / char at a time and display them to see what's going on. Let us know what you find!
Originally posted by Yaroslav Chinskiy:
You can try to create a queue and queue reader that sends data over the sockets. The other threads will put messages on that queue.
Originally posted by Mani Ram:
It mean that the method or the attribute has class scope (i.e they are static)
Originally posted by Stan James:
Yup, show us where you're going in a little more detail. You can't have multiple threads reading from the same socket at the same time. But you could have a driver that reads a message and hands it off to a thread for handling. The driver could read at the speed of the network and not be slowed down by the server code that runs in response to each message.
The logic would be something like:
Hmmm, there must be a cleane way to say that without three reads. Lemme know if that's going the right direction.
If you get tons of messages faster than you can handle them you'll wind up with tons of threads which could be very bad. If the number of threads or the overhead of creating them becomes a problem, look into thread pools. The Jakarta Commons has a nice one.