Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Winsock sendata solutions 1

Status
Not open for further replies.

mibosoft

Programmer
Jul 23, 2002
106
SE
I have integrated a winsock server in my app and have some problems with respone time and broken connections. My server returns HTML code (a user form) with the senddata() method. Sometimes, only half forms are shown in the users browser and it takes long time. I have played some with the size of packets sent but the problem remains. If the internet connection is good, there are no problems at all.

I would be grateful for hints on how to solve the dataarrival and senddata part of the server. I have played some with the senddatacomplete event but it seems that this event doesn't trigger for all connections but only some. Is this true? My thought was that this is the place where a connection shall be closed but then I must be sure that it trigger.

Thanks'
Micael
 
Hi Ron,
I actually develop in VFP but it seems to be more examples out there for VB so I tried this forum.

What I would like is to see source code for any well working server using the winsock control, especially the dataarrival, senddata and sendcomplete parts. In other words, I'm interested to learn how to optimize the senddata part to get.

Thanks'
Micael
 
The first thing is to be sure you are using the latest version of the Winsock control that is available. There were numerous fixes over the years to address memory leaks and event-related issues in programs using more than one control.

I don't track VFP versions and updates, but you'll want the one that is part of VB6 SP6B.

The SendDataComplete event is raised when the control can accept more SendData output. If you have no more to send, then sure, go ahead and Close there.

SendData does not send "packets" so get that out of your head. You can send a great deal of data in one go if need be, there is no need to chunk it out in pieces unless you have some other reason to. If you send ~ 8K chunks per call you should minimize the time SendData blocks though, without impairing transmission performance. Your mileage may vary, etc.

You might find the example you want in Gossamer - Yet Another Web Server. It is a UserControl that provides a simple embedded web server.
 
Thanks' for your input dilettante!

1) You say that the SendDataComplete event is raised when the control can accept more SendData output. Does that mean it should trigger after every sendata?

2) You say that there is no need to split senddata into chunks but if I don't, the the receiver (web browser) will get a "Page load error". How come?

/Micael
 
Yes, I believe that each SendData should result in a SendComplete event. if not it would break lots of programs. In any case be sure you use the latest version of the Winsock control.

I have no idea why you're seeing page load errors.
 
I've searched the whole internet without finding a) what's the latest version of MSWINSCK.OCX and b) where can I download it :-( Anyone who can tell me?
 
Should be part of a VFP Service Pack I'd think. There has never been a separate download that I know of.

I have MSWINSCK.OCX version 6.1.97.82 here.
 
Ok, I've got the same version. Thanks' for your hints.

I will perform some heavy debugging and tuning of the server with the next couple of days and hopefully, I'll learn something.
/Micael
 
Problem solved, thanks' dilettante!
Solution:
1) Send all data in one single sendata() call. Do not split in chunks and do not close the connection in the dataarival event.
2) Add the sendcomplete() event and close the connection here.

(Also, it's important to have the procedure error(). If not, broken connections will lead to memory bloat.)

Great!
Micael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top