Re: client socket to read individual messages



"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


.



Relevant Pages

  • Re: I want to write a network printer server...
    ... Then why not just make your printer a shared printer? ... server of your devising, so you can make it do anything you want. ... Open a socket, start sending data. ... you could use a protocol where you send the ...
    (microsoft.public.vc.mfc)
  • Re: client socket to read individual messages
    ... It's a common _and_ common-sense technique. ... defining a protocol, and message-length ... I recently had to devise a simple protocol of my own for a socket situation. ... and one classic solution for that problem is to write a little server ...
    (comp.lang.java.programmer)
  • Re: Letting a Python application phone home
    ... You need to define a protocol for the communication ... Look at the python module "socket" resp. ... "SocketServer" for low level tcp functions. ... let your program contact the server periodically. ...
    (comp.lang.python)
  • win32 socket, "Operation not supported"
    ... I have written an app which opens a TCP connection to a server and uses a protocol to communicate with it. ... available on a read socket, a full packet is read in a blocking fashion from the socket. ... The server side periodically sends updates on the state of the molecular dynamics engine. ...
    (comp.lang.python)
  • Port Assignment- OT in a Small Way
    ... 5:RJE - Remote Job Entry ... 18:MSP - Message Send Protocol ... server, Traitor 21, WebEx, WinCrash, NerTe, ... 22:SSH - SSH Remote Login Protocol, RAT: Shaft ...
    (comp.security.misc)