Re: client socket to read individual messages
- From: "Arved Sandstrom" <asandstrom@xxxxxxxxxxxxx>
- Date: Sat, 31 Jan 2009 01:15:40 GMT
"Arne Vajhøj" <arne@xxxxxxxxxx> wrote in message
news:498272d3$0$90276$14726298@xxxxxxxxxxxxxxxxxx
John B. Matthews wrote:
In article
<5420c86e-5a2e-471e-8fed-1412a96540d7@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
kishan.bisht@xxxxxxxxx wrote:
Basically I am looking for two way communication in single client socket
connection where I am able to understand individual messages sent by
server socket.
In the thread you cited, the suggestion of using a length to frame the
individual messages seems appealing.
Very appealing. That is how it is done.
Arne
It's a common _and_ common-sense technique. What it boils down to is, you're
defining a protocol, and message-length (or length of part of the message)
is one way of describing a message. HTTP 1.1 uses both headers and
length...this protocol is a source of ideas for anyone looking to write
their own, which is essentially what the OP needs.
I recently had to devise a simple protocol of my own for a socket situation.
Readers here will know about Runtime.exec behaviour on Solaris and Linux,
and one classic solution for that problem is to write a little server
running in a stripped-down JVM to handle the Runtime.exec's. Of course, you
now need to communicate with this server from your main app, hence a
protocol. In my case the protocol was: send two lines (newline terminated)
to the socket server...period. The main app expected one line back, after
which the connection was closed. Very simple.
We have another situation where we'd like to use this "miniserver", but this
time the message will have a payload. In which case we'll need to
differentiate between message types and also describe payload length...both
easily handled by headers just like in HTTP. In effect my existing message
type just consists of 2 header lines.
AHS
.
- References:
- client socket to read individual messages
- From: kishan . bisht
- Re: client socket to read individual messages
- From: John B. Matthews
- Re: client socket to read individual messages
- From: Arne Vajhøj
- client socket to read individual messages
- Prev by Date: Re: The yearning for a preprocessor
- Next by Date: Re: K-D tree or something similar
- Previous by thread: Re: client socket to read individual messages
- Next by thread: Re: client socket to read individual messages
- Index(es):
Relevant Pages
|