• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Re:FTP query

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using a frame to display a button which when clicked should
ask for downloading a file from a server on the client side.

My code looks like this---
try
{
// To open socket.
Socket clientsocket =new Socket("192.168.0.108",21);
DataOutputStream outbound =new DataOutputStream(clientsocket.getOutputStream());
BufferedReader inbound =new BufferedReader(new InputStreamReader(clientsocket.getInputStream()));
outbound.writeBytes("GET /CyberSync_2000.exe /FTP\r\n\r\n");
System.out.println("ftp reguest sent.....to sever");

---but it is not giving the desired results.
can someone help?

thanks in advance.

[This message has been edited by sunil kumre (edited March 14, 2001).]
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
would u tell me what exceptions it throws ....
 
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How exactly is it not working? Does the site require a login with username and password? Can you be more specific about your problem?
 
sunil kumre
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi maateen,
It's giving
java.net.exception: connection refused: No further information..

I'm also tried for FTP servlet..
But not get How to write FTP servlet???
Do you have any Idea about FTP servlet???
Thanx
 
Rahul Rathore
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sunil
You say that java.net.exception is displayed, but there is NO class named java.net.exception or java.net.Exception in the java.net package.
The only exceptions in java.net package are:-
BindException, ConnectException, MalformedURLException, NoRouteToHostException, ProtocolException, SocketException, UnknownHostException, UnknownServiceException
So which exactly is the exception thrown? Solving the problem without specific information is difficult.
Also, if your ftp server-site requires a username, password, then the first command that should be sent over the socket is a login command supplying the username and password. That may be the reason why GET causes connection refused message.
You can also use URL or URLConnection class to download from the ftp site. The code is much simpler:-
URL url=new URL(protocol:resource);
InputStream uin=url.openStream();
...
If the site requires username and password then do as follows:-
URL url=new URL("ftp://username :password@ftp.yourserver.com/pub/file.txt");

[This message has been edited by Rahul Rathore (edited March 15, 2001).]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic