开发者

FTP upload via sockets

开发者 https://www.devze.com 2022-12-28 14:36 出处:网络
how can I upload a file with sockets to a ftp server? I am readi开发者_StackOverflowng something with \"STOR\" in RFC...It is the same how i transfer a file between two computers?A sample code would b

how can I upload a file with sockets to a ftp server? I am readi开发者_StackOverflowng something with "STOR" in RFC...It is the same how i transfer a file between two computers?A sample code would be helpfuly...thanks


I don´t advice to use raw sockets to upload FTP files, instead use something like SimpleFTP, it's easier to use and it will save you a lot of time. And since you're learning Java, you should do it on the easiest possible way.


JavaWorld presents a discussion of some FTP client libraries. To begin with, they even teach you how to use the "built-in" Java URLConnection to do FTP with in a simple way. That should get you started!


Instead of uploading a file to a ftp I'd suggest that you write your own server and client software and have them communicate with eachother if you want to learn to use sockets in java.

When you have learned that you can read the RFC for ftp which should tell you how to communicate with the FTP server. You need to learn and understand the ftp protocol in order to construct valid packets with data to send and in order to parse the data you receive from the ftp server.

its usually requests, responses and data sent back and forth.

Filedata itself is just sent in its raw form unless the ftp server requires encryption, but requests and responses can be in any form, binary values, decimal values, strings etc all depending on the protocol and the type of request.. You need to know this to setup a valid communication channel.

I don't know the ftp protocol myself so I'm just demonstrating examples so you'll easier understand what it's all about.


You really do not want to write your own implementation of the FTP protocol - it's not as simple as it might seem at first glance.

I'm using commons ftp , which gives you a nice API to all ftp operations.

If you don't need that much control, you could use URLConnection from the standard java library.


What language are you using? You can use the FTP functions if you have access to the APIs.

0

精彩评论

暂无评论...
验证码 换一张
取 消