|
-
May 29th, 2001, 08:22 AM
#1
Thread Starter
New Member
FTP Connection ..
Hello!
Am having problems with a ftp connection that has been established, which I can send commands to and from but I cannot transfer (upload) the file.
All that I can see is that I get a timeout message from within the .dll file that I call.
The fun part with this though, is that if I do step through the FTP-section of the code it works great. I can connect, I can issue commands (cwd and type i), and I can put the file on the server.
If I - inside the ftp function - place breakpoints after I have logged on to the server and at the error message to the sendfile function - and run from the first breakpoint to the other, it won't send the file. It gets this timeout message.
And then I have also put some waiting loops after all my ftp functions just in case it is something that needs some extra time to finish. (10 second intervals between the commands) The timeout is set to 45 seconds.
If I place a breakpoint before I head into this ftp-function and one after it is finished - it won't put the file on the server. The rest of the commands work though.
If I compile it as an .exe file with the required references to the .dll file and run it though - it won't put the file on the server.
The rest of the commands work though.
Have anyone ran into this same problem before? Would be really grateful for all suggestions/hints/tricks/whatever...
-
May 29th, 2001, 08:30 AM
#2
Addicted Member
I do a lot of client/server work, and I've seen something similar. It has to do with all the delaying functions you put it. Try taking then all out, and not setting any breakpoints. If the code is allowed to execute at its own pace, it may work. The server expects a certain amount of communication from the TCP (or UDP) line, and making your program stop like that halts the communication. The server probably thinks your computer froze. If removing the delays doesn't help, I'll cogitate some more 
Just a side note, you're smart for posting here...I went through a couple days of hell wondering why my prog couldn't keep up with MS Outlook, and it was because of a DoEvents I had in the socket sending routine
Things I've Said:
"Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
"Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
"You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"
-
May 29th, 2001, 09:13 AM
#3
Thread Starter
New Member
I tried that, but it didn't work.. the delays I'm having in my program is between the type of commands that you perform while doing manual ftp. (cd, binary mode, and put) The tcp code in itself is pacing along on it's own already. A slight warning should be in place though, I don't know tcp at all..
I've debugged the .dll as far as I can, and this is what seems to happen.. (the code listed below is from the .dll file)
The WritetoFile's are my way of trying to locate the error. It seems to work, since the PORT and the STOR command is working perfectly in all cases, but the WaitForConnectionRequest is returning false when I'm not stepping through the code that calls this .dll function.
Why would this work when I am stepping through the code? I run exactly the same thing, with exactly the same parameters when I'm stepping/debugging as when I try to run it (both in debug and as a .exe file). I have really no clue.
'
' Open listen socket and init transfer
'
Load frmWinSock.tcpClient(1)
frmWinSock.tcpClient(1).LocalPort = 0
frmWinSock.tcpClient(1).Listen
frmWinSock.gbConnectionRequest = False
' Send PORT command
If SendPortCmd(1) = False Then
Call WritetoFile(sFile, "SendPortCmd is false!")
FTPSendFile = False
Exit Function
End If
' Initiate transfer
SetCmd sTmp, "STOR " & RemoteFile & vbCrLf
'SetCmd sTmp, "RETR " & "skan.txt" & vbCrLf
frmWinSock.tcpClient(0).SendData sTmp
If WaitForMessage("150", "200") = False Then ' Opening connection
Call WritetoFile(sFile, "WaitForMessage 150,200 is false!")
FTPSendFile = False
Exit Function
End If
' Wait for server to do a conn. request on listener socket
If WaitForConnectionRequest() = False Then
Call WritetoFile(sFile, "WaitForConnectionRequest is false!")
FTPSendFile = False
Exit Function
End If
' Close listener
frmWinSock.tcpClient(1).Close
Unload frmWinSock.tcpClient(1)
And, well, smart and smart, that's .. not really true .. it's been bugging me for more then a week now, and I'm really starting to grow tired on banging my head on the desk now. =)
-
May 29th, 2001, 03:49 PM
#4
Addicted Member
It may be that your program isn't giving the server enough time to respond. That would explain why it would work when you step through it (each command has plenty of time to execute). I'm not sure what I was thinking in my last post; I gave you the solution for if you were writing a server, not a client (We'll just say that I was thinking ahead in your VB network programming career )
Try putting "DoEvents" after crucial WinSock functions, such as opening/closing/sending data. That'll give them time to finish executing the command. Don't put anything like a "Sleep" function, since that completely halts your programs so nothing will execute.
Good luck!
Things I've Said:
"Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
"Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
"You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"
-
May 30th, 2001, 01:42 AM
#5
Thread Starter
New Member
I'll take a further look at it, and thanks for your help with this.. I appreciate it. :-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|