Hi Robert,

Just for the record everything works fine.

Thanks for your feedback.

simply check the byte count returned by ReceiveStr.  It works great.

Just a quick note: Receive() is better than ReceiveStr() unless your protocol is text and line oriented. Look at the source of ReceiveStr() and you'll see that data is copyed into a string while in Receive(), data is simply moved in your own buffer. Your application will use less CPU if you receive the adta directly where you will use it. Moving data around with strings is easy programming but result in a high CPU use and tend to memory fragmentation. Also you'll have more difficulties - and slowness - when you'll use Delphi 2009 which use unicode string (16 bits chars). Using strings for anything which is not really a string will cause you some trouble.

My 2c...

--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

----- Original Message ----- From: "robertoschler" <robertosch...@yahoo.com>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Saturday, June 06, 2009 5:52 AM
Subject: Re: [twsocket] TWSocket stops receiving where TClientSocket justkeeps going



Hello Wilfried,

Just for the record everything works fine. Hopefully someone else can benefit from my little journey here. I no longer check RcvdCount and simply check the byte count returned by ReceiveStr. It works great.

This is a relief because ICS is my preferred choice for socket work.

Thanks for listening,
Robert

--- On Fri, 6/5/09, robertoschler <robertosch...@yahoo.com> wrote:

From: robertoschler <robertosch...@yahoo.com>
Subject: Re: [twsocket] TWSocket stops receiving where TClientSocket just keeps going
To: "ICS support mailing" <twsocket@elists.org>
Date: Friday, June 5, 2009, 8:40 PM

Hello Wilfried,

Well now I know the problem. The Overbyte web site
says RcvdCount is unreliable. Their example shows the
use of a 8192 size buffer in Data Available to receive
whatever data may be there and to check the return of the
Receive() call to know how much data was delivered. I
assume this means that the maximum amount of data received
during any Data Available event is 8192.

It's amazing how so small a thing can cost you so much
time. I'm going to recode and retest now.

Thanks,
Robert

--- On Fri, 6/5/09, robertoschler <robertosch...@yahoo.com>
wrote:

> From: robertoschler <robertosch...@yahoo.com>
> Subject: Re: [twsocket] TWSocket stops receiving where
TClientSocket just keeps going
> To: "ICS support mailing" <twsocket@elists.org>
> Date: Friday, June 5, 2009, 8:10 PM
>
> Hello again Wilfried,
>
> A little extra data. My Data Available event
handler
> grabs the number of waiting bytes in the queue from
the
> RcvdCount property (I use it to size the receive
> buffer). If the byte count is 0, I just ignore the
> Data Available event. That is, I do nothing. I
> just added code to the Data Available event handler to
add a
> line to my session log whenever I get a Data Available
event
> where the RcvdCount is 0. I'm getting a ton of Data
> Available events where the RcvdCount is 0 on the
plain
> vanilla TWSocket instance connected to the image
streaming
> server. Any ideas what could cause that to happen?
>
> Thanks,
> Robert
>
> --- On Fri, 6/5/09, robertoschler <robertosch...@yahoo.com>
> wrote:
>
> > From: robertoschler <robertosch...@yahoo.com>
> > Subject: Re: [twsocket] TWSocket stops receiving
where
> TClientSocket just keeps going
> > To: "ICS support mailing" <twsocket@elists.org>
> > Date: Friday, June 5, 2009, 7:43 PM
> >
> > Hello Wilfried,
> >
> > Thank you for your reply.
> >
> > It appears to be something with my application
but I
> don't
> > know what. I grabbed your SocketSpy program and
set
> it
> > up to act as a proxy between the streaming image
> server and
> > my program. Your log kept accumulating
incoming
> data
> > from the server while my app, which was connected
to
> > SocketSpy as an incoming client, stopped firing
> > DataAvailable() events after a certain number of
> received
> > frames, just as I described before.
> >
> > Now some details. My app is also a proxy
server
> like
> > SocketSpy. I looked at the SocketSpy code and
here
> is
> > the only crucial difference I could find between
your
> code
> > and mine. When your server socket accepts a
> connection
> > you create a client socket that creates it's own
> REMOTE
> > client socket when a new connection is
accepted.
> This
> > REMOTE client socket immediately connects to the
other
> end
> > other end of the proxy link. From the client
> socket's
> > Data Available handler you immediately send the
data
> to the
> > REMOTE socket and vice-a-versa.
> >
> > In my program when I accept a new connection
with
> > TWSocketServer I just create a client socket.
This
> > results in a message being posted to the host
form
> telling
> > it a new client has been connected and the
current
> > connection count. If the client count is now
> greater
> > than 0 for the first time, a single plain
vanilla
> TWSocket
> > control then connects to the streaming image
server
> > completing the other end of my proxy link.
(Details
> on
> > why I use this architecture are below).
> >
> > To facilitate data transfer I use windows
messages
> posted
> > to the host form. When *any* of the Clients to
> > TWSocketServer fire the Data Available event, I
post
> a
> > message to the host form notifying it of the new
> data.
> > The host form then calls SendStr() on the single
> plain
> > vanilla TWSocket control connected to the image
> streaming
> > server. Conversely, when the plain vanilla
TWSocket
> > control fires its Data Available event, a message
is
> posted
> > to the host form who then sends the data to ALL
> clients
> > connected to the TWSocketServer instance.
> >
> > I do this so I can have a one-to-many proxy
link,
> where
> > multiple clients can receive the image stream
from the
> image
> > server. Also, I use the windows messaging
technique
> > for safety purposes so that I am not trying to
send
> large
> > amounts of data to the other end of the proxy
link
> from
> > within the Data Available handler itself. By
using
> > windows messages to trigger the sends I am moving
the
> send
> > outside the scope of the Data Available handler.
> >
> > Note, I have code in *every* event handler for
all
> sockets,
> > including for the Error and BgException events,
and I
> am not
> > getting any error reports. I also check all
> > ErrorCode's on those events that provided that
> parameter,
> > and report any non zero code ErrorCode
occurrences.
> > There have been no such occurrences.
> >
> > Do you have any ideas for tests or tips on trying
to
> > diagnose why the Data Available event on the
plain
> vanilla
> > TWSocket component connected to the image
streaming
> server
> > would go dead after receiving successfully for a
> short
> > time?
> >
> > Thanks for your help,
> > Robert
> >
> >
> > --- On Fri, 6/5/09, Wilfried Mestdagh <wilfr...@mestdagh.biz>
> > wrote:
> >
> > > From: Wilfried Mestdagh <wilfr...@mestdagh.biz>
> > > Subject: Re: [twsocket] TWSocket stops
receiving
> where
> > TClientSocket just keeps going
> > > To: "ICS support mailing" <twsocket@elists.org>
> > > Date: Friday, June 5, 2009, 3:30 AM
> > > Hello Robert,
> > >
> > > To be absolutely sure if it is the sending
or
> > receiving
> > > application I
> > > suggest you put SocketSpy between it. You
find it
> on
> > user
> > > made page.
> > > Then we are sure in wich application is a
bug and
> we
> > can
> > > search deeper.
> > >
> > > ---
> > > Rgds, Wilfried [TeamICS]
> > > http://www.overbyte.be/eng/overbyte/teamics.html
> > > http://www.mestdagh.biz
> > >
> > > Thursday, June 4, 2009, 17:58,
robertoschler
> wrote:
> > >
> > >
> > > > I have an application that opens an
> outgoing
> > > connection to an MJPEG
> > > > streaming server (server push using
MIME
> > multi-part
> > > boundary method).
> > > > With my TWSocket code, I connect fine
and
> then I
> > get
> > > an arbitrary
> > > > number of frames until the connection
> appears to
> > stop
> > > receiving data,
> > > > permanently. The data available
event
> never
> > > fires again until I close
> > > > the connection and reconnect. This
> happens
> > > pretty quick. Sometimes
> > > > it's a small number of frames (e.g. - 1
to
> 7).
> > > Other times I get a
> > > > nice chunk of about 30 to 50 frames,
but
> always
> > the
> > > data reception
> > > > just dries up.
> > >
> > > > To make sure the server was not
stopping
> > transmission,
> > > I coded up a
> > > > simple example using the included
Delphi 6
> > > TClientSocket component. I
> > > > set it to non-blocking mode which is
how I
> use
> > > TWSocket too. It did
> > > > not exhibit the problem. It kept
> receiving
> > > frames until I shut down
> > > > the connection.
> > >
> > > > How can I diagnose and or fix the
problem
> with
> > my
> > > TWSocket code? I would prefer to use that
> instead.
> > >
> > > > Note: I am using Delphi 6 Pro and ICS
> version 5.
> > >
> > > > Thanks,
> > > > Robert
> > >
> > >
> > >
> > > > --
> > > > To unsubscribe or change your settings
for
> > TWSocket
> > > mailing list
> > > > please goto > > > > http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> > > > Visit our website at http://www.overbyte.be
> > >
> > > --
> > > To unsubscribe or change your settings for
> TWSocket
> > mailing
> > > list
> > > please goto > > > http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> > > Visit our website at http://www.overbyte.be
> > >
> >
> >
> >
> > --
> > To unsubscribe or change your settings for
TWSocket
> mailing
> > list
> > please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> > Visit our website at http://www.overbyte.be
> >
>
>
>
> --
> To unsubscribe or change your settings for TWSocket
mailing
> list
> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>



--
To unsubscribe or change your settings for TWSocket mailing
list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be




--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to