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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stack Overflow 1

Status
Not open for further replies.

Webrookie

Programmer
May 18, 2000
112
US
I have written a program using sockets to send and retrieve information between a client and a server. My problems comes when I try to download a large file or a couple of smaller files...i get a stack overflow error on my client interface.....when I view the stack I see that the procedure used to receive the file is called over and over...so I have narroed my problem down.

I have limited the number of doevents clauses down to only the essentials....I have no fixed length strings...etc..

Now how do I go about fixing this? I was thinking that if I took this procedure and put it in it's own thread perhaps? I am a major newbie when it comes to threads. What are my possible solutions?
 
"when I view the stack I see that the procedure used to receive the file is called over and over...so I have narroed my problem down. "

Take a look at that procedure. does it declare any static varibles, or is the procedure itself called recursively. (does the procedure call itself). If it does, I recommend re-coding it to eliminate any recursion.

Amiel
amielzz@netscape.net

 
If you have a huge receive buffer, try making it smaller. Chances are that the receive_data event is getting fired and you're processing the data in the event when it get's fired again. If you make it smaller or do less processing in the receive_data event, you're likly to let the routine finish before it gets called again.

Snaggs
tribesaddict@swbell.net
 
ok, the procedure which receives the files has a case statement which makes decisions based on input parameters...well, the receive code is only one case. There are, as a maater of fact amiel, two static variables declared, but in a different case, does that matter? The Procedure is not called from within itself.

Regarding your idea, Snaggs, do you think if I moved the receive case into it's own separate procedure and merely called that procedure in the case statement....would that be possible.

Well, I will try messing with this stuff. Thanks for your help gang. I'll let you know.
 
You can try this little technique to determine when and where the routine is getting called from. Create a "Static" integer variable in the routine called Counter. Then add the following lines:

Counter = Counter + 1
If Counter = 10 Then Stop

What this will do is let the program run full speed and then stop after 10 calls to the routine. Then use Ctrl-L to look at the call stack. Go backwards through the stack and determine at what line the routine got interrupted. Go back to the next call in the stack and do the same thing. See if you can find a pattern from where it's getting called.

What are your other two static variables for in your routine?

and

How are you handling the incomming data in the receive buffer? Snaggs
tribesaddict@swbell.net
 
Hey, I haven't gotten around to making those changes yet, but I stopped by to see if anyone responded...ok:

my other two static variables are a string and a long

the incoming data in the receive buffer is being appended to a global variable....which eventually becomes a string of binary data and then I use the put statement to save the file....
 
ok, I'm bringing my old thread back...I didn't have a lot of time to look at it with christmas and all. ok, i'm sure i fixed my dilema of the stack overflowing. When my server socket ran the procedure to send the file it was taking the whole file (via the input function) and sending it. Then my client socket would basically make recursive calls to the data_arrival event until the file was completely downloaded. This method required me to slap in a doevents and this did not work with larger files.

So what I did was use the input function to only take 8096 characters at a time and send them..when the client was finished, the server would send the next 8096. So here's my new dilema: My transfer rate drops lock a rock until about 45k/sec and then slows down, but still drops.....

here's the code on my server that sends the file:

-----------------------------------------------------------
Do While Not EOF(1)
FileData = Input(8096, 1)
server(index).SendData FileData
Do Until SendingFile Or AbortFile Or DoEvents = 0
DoEvents
Loop
SendingFile = False
AbortFile = False
Loop
-----------------------------------------------------------

as you can see, my code waits for a response before sending the next chunk.

any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top