Link to home
Start Free TrialLog in
Avatar of enigmasolutions
enigmasolutions

asked on

When to use Indy TcpServer.IOHandler.WriteBufferOpen

Hi,

In our application I notice we are using IOHandler.WriteBufferOpen as follows:
On the client AND on the server we are doing something like this...

        Connection.IOHandler.WriteBufferOpen;
        try
          Connection.IOHandler.Write(   Some Stream Data    )
          Connection.IOHandler.WriteBufferFlush;
          Connection.IOHandler.WriteBufferClose;
        except
          Connection.IOHandler.WriteBufferCancel;
        end;

Our application is a typical client server application (an accounting software package actually) where the client sends small requests for data and the server returns varying size streams of data.

We are getting problems connecting to a server that is running on a very poor internet connection (3rd World Country - 256kbps internet).

A short packet of information such as the initial login works.  But then we get Read Timeouts when a slightly larger packet of information is being sent from the server to our client.  Interestingly, we don't get any problem sending huge data the other way (even with writebuffer used on our client) - I guess that is because our internet technology is much better.


I am most interested in QUESTION 2 (below) because I want to understand wny my developers may have used it.


Question 1 -  Should we get rid of the WriteBuffer code?

Question 2 - In what scenarios would you use WriteBuffer?

Question 3 - Please confirm - Setting UseNaggle:=false will not help?

Question 4 - Please confirm - Setting that ReuseSocket:=rsTrue will not help?
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

with Indy all I can say - use newest version available. Because I'm not happy with it, I use
ICS a lot. From start it is dificult (sync versus async). Synapse is another good component. Some users records problems with Indy:
http://stackoverflow.com/questions/2663494/indy-or-ics-or
UseNaggle should work ...
http://stackoverflow.com/questions/605580/indy-write-buffering-efficient-tcp-communication but as I said - with indy never knows. Some users are very happy with it.
http://stackoverflow.com/questions/9588198/which-indy-components-to-use
Beacuse socket leaves more time then connection itself ReuseSocket can help when you use a lot of Open - Send - Close sequences to same address, but I suggest to do no use ReuseSocket:=rsTrue
Avatar of enigmasolutions
enigmasolutions

ASKER

I am trying to get an answer on whether we should use writebuffer???

Now, I have been thinking that maybe we introduced the use of writebuffer to avoid hanging.  
For example the client is expecting to receive "Some Data" of a certain size.  And if it doesn't get all the data for some reason then the client may just hang.  I am not sure about this.

I just need someone to help me that really know what writebuffer is used for.
And MORE IMPORTANTLY when to use it?

In response to Sinsav, for now I just want to understand INDY (can look at alternatives later).  I agree UseNaggle should work.  I agree that ReuseSocket=rsTrue sounds like a bad idea.
Well I am testing it now without using the WriteBuffer AND I set UseNaggle=false (for good measure).  It is working now.  But the real test will be when they have a few users doing other things on their 256 kbps internet.

I will post the results in a few days.

Still it would be nice to get some official wisdom on the use of WriteBuffer.
OK, My program works a lot better without WriteBuffer.  It is much more stable.

But if I rush the program, ie try to do a few commands quickly it occasionally stuffs up the connection - giving what appears to be packet loss.  But it could just be that my customer has the world's worst internet (seriously - it is bad).

Although I can't get it to bug out now - so can't get exact error message.
ASKER CERTIFIED SOLUTION
Avatar of enigmasolutions
enigmasolutions

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No other reasons can explain the question