This was posted on the programming forum at my board here:
http://www.worldrule.com/forums/show...p?threadid=620
and I decided to post it here, so maube you guys can help!
Quote:
Java und Ftp
Hi .. I've a bit of a problem ..
main reason I joined up here but hey ..
Ok Problem ..
I've setup a socket that's connected to the ftp server, I've connected and logged in.
I write the text instructions to the ftpdaemon to the outputstream of this socket and read the input text from the daemon from the inputstream.
When I want to upload a file, I startup a serversocket at port 0 (a free port and send the daemon the text about the port(using out), no problems so far.
I send the daemon (using out) a STOR command .. out.write("STOR blah.txt\n"); and then I setup a socket waiting for a connect on the serversocket I setup and told the daemon about ..
I get a connect and send the file down .. thats all ok ..
BUT
when I try to do it again .. its messed up. I use a new serversocket and tell the daemon abou the new serversocket
but it freezes when waiting for a connect .. the daemon never tries to connect to it when I send it the stor command
Does anyone know whats up?
All the connections except the in/out for the main connection to the ftp server at port 21 are local to the method. If I upload a file, its ok .. it leave the method (and should clean everything up ..) but when I tell the ftp daemon (the server I want to connect to) the new port and tell it I want to send a file, it doesn't try connect ot the new serversocket..
arg
Thanks in advance
Balmark
ps.
I'm not 100% sure about what the ftp daemon wants ..
Do I need to setup a seperate serversocket for the data connection or can I use the same one ?
I'm assuming (due to major lack of documentation that its like this..
S1 = main socket connection ..
D1 = 1st data connection
D2 = second data connection
S1> PORT (the infor for my ip and the port I'm listening on D1 atm)
S1> STOR blah.txt
- server makes a connection to the serversocket D1 -
D1> I send down the file
S1> -server tells me transfere complete-
S1> PORT (new info for D2)
S1> STOR anotherfile.txt
- server makes a connection to the serversocket D2 -
(*** problem is here .. the server never tries to connect to D2 ***)
D2> I send down the file
S1> -server tells me transfere complete-
|
thanks guys I appreciate your help in advance!