🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
2 messages
2 total messages Started by Josh Arnold Thu, 28 Sep 2006 17:31
Problem separating messages...
#1909
Author: Josh Arnold
Date: Thu, 28 Sep 2006 17:31
17 lines
1532 bytes
Now that I have my sockets "working" I have the following problem.

I send a short message (all ASCII) to the server (an emdedded device in this
case). The server receives the message from my application and then
formulates a response.

I send a lot of these short messages rapidly.

The problem is that when my application receives the responses they are all
lumped together in a single message.  This makes it impossible to parse.

What is the trick to getting the OnRead event to fire onece for each
message?  Does the response from the server need to be terminated with a
special character?

Thanks in advance,
Josh
Re: Problem separating messages...
#1911
Author: Remy Lebeau (TeamB)
Date: Thu, 28 Sep 2006 18:10
34 lines
2226 bytes
"Josh Arnold" <jarnold@atterotech.com> wrote in message
news:451c0548$1@newsgroups.borland.com...

> The problem is that when my application receives the responses
> they are all lumped together in a single message.

As they should be.  That is how TCP-IP works in general.

> This makes it impossible to parse.

What does the data actually look like?  If the individual message lengths
are not known ahead of time, and there are no unique delimiters between
messages, then there is no way you will be able to handle multiple responses
at a time.  You will have to wait on sending a new request until the
previous response has been recieved first.

> What is the trick to getting the OnRead event to fire onece for
> each message?

There isn't any, because that is not how TCP/IP works to begin with.  TCP/IP
is a byte stream, not a message stream.  The OnRead event is fired when new
bytes arrive, however many that may be.  It is the application's
responsibility, not the socket's, to buffer the bytes and then process them
as formatted messages as needed.

> Does the response from the server need to be terminated with a special
character?

Yes, if the messages are not fixed in length, and the lengths are not being
included inside the message data.


Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads