LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-22-2000, 07:14 PM   #1
eraser
Member
 
Registered: Aug 2000
Location: US
Posts: 47

Rep: Reputation: 15
Question


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!


 
Old 10-13-2000, 12:36 PM   #2
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 12,766

Rep: Reputation: 3558Reputation: 3558Reputation: 3558Reputation: 3558Reputation: 3558Reputation: 3558Reputation: 3558Reputation: 3558Reputation: 3558Reputation: 3558Reputation: 3558
Not sure what language he is using, which makes it kind of tough. FTP uses 2 ports in active mode (default) or 1 port in passive mode. Here are a few socket programming references.

http://www.ecst.csuchico.edu/~beej/guide/net/
http://www.lcg.org/sock-faq/

I would also recommend getting the source of a GOOD ftp server and it closely. If he has any other more specific questions let us know (or point him here).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hi guys! einnor LinuxQuestions.org Member Intro 5 01-28-2005 01:32 AM
Oh my G-d, you guys will NEVER believe this: Squall General 21 03-18-2004 09:47 PM
GUYS!!! I need your help Jetta-GT- Linux - Newbie 1 01-09-2004 01:03 AM
Sorry guys Dumpsterm0uth LinuxQuestions.org Member Intro 0 05-18-2003 07:24 AM
I'm new. Can you guys help me out? AppleMac Linux - Newbie 5 09-27-2002 12:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration