Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: Probably hit by TCP buffer!

www.cryer.info
Managed Newsgroup Archive

Re: Probably hit by TCP buffer!

Subject:Re: Probably hit by TCP buffer!
Posted by:"m utku karatas" (m.utku..@g_o_o_g_l_e_smailservice.com)
Date:23 Jun 2006 04:28:20

"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote in
news:449b77c4@newsgroups.borland.com:

...snip
>TIdTCPServer is already multi-threaded.  Why are you using more threads
>thn
>you need to?  Inside the OnExecute event handler, you can do the
following:
>procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
>    begin
>        fData :=
>AThread.Connection.ReadString(AThread.Connection.ReadInteger(False));
>        AThread.Synchronize(Sync_OnReceivedData);
>    end;

I keep the code a little abstracted so at some point I can switch to
other IPC technics.


...snip
>
>>          size := fSocket.ReadCardinal(False);
>>          fData := fRunSocket.ReadString(size);
>
> Why are you reading from two different sockets?  Or is that just a
> typo?

Oh that's a typo. Operating only one socket - fSocket.


>> void SendData(){
>>     ........
>>     sock.Send((char*)&size, sizeof(int)); // using my simple wrappers
>>     sock.Send(data.c_str(), size);
>> }
>
> You are sending an 'int' for the string length, but you are having the
> server read a Cardinal instead.  ReadString() can't take a Cardinal to
> begin with.  Notice above that I changed the reading code to receive
> an Integer instead of a Cardinal.
>

Thanks for the heads up.

...snip
> What is 'sock' declared as?  What does Send() look like inside?

Nothing fancier than the winsock's send function, a simple wrapper.


>> I am told that the problem relates to TCP buffer but how is it
>> possible that it gets full when the server is insistingly try to recv
>> from the socket(see Delphi code above)?
>
> There are several possibilities:
>
> 1) you are reading from two different socket object (unless that was
> just a typo) in which case you are leaving data in the socket, which
> will then cause the sender to block until the socket is emptied.
> 2) Sync_OnReceivedData() and/or Synchronize() has become blocked, so
> the reading is blocked and the socket fills up with unread data.

I wish it was. The interesting thing is that while client's(C++ one) Send
call is blocked, the server is also blocked in the ReadCardinal func. The
server is eager to recv but client is frozen while sending.

>> BTW what would you use to peek on this TCP buffer?
>
> TCP does not (reliably) support peeking.  In Indy's case, if the data
> has already been read into TIdTCPConnection's InputBuffer, then you
> can peek the data from that.

Not asking the coding way, I meant a tool like Ethereal hooking directly
windows' connection. Any recommendation on that?

Thanks.


--
Best regards.

M. Utku Karatas

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive