Google says that somebody here is working on an Arduino 'Tiny FTP Server' which seems like the sort of thing you're after. There's no firmware there but hints that it is / will be published in a separate article. As long as your network adapter is capable of supporting two simultaneous TCP connections I don't see any reason why you couldn't write your own FTP server - the protocol isn't especially complex.
I try to do something, but not advanced for port 21.
I've checked and can not find the source of the problem.
My arduino ethernet shield does NOT respond with port 21.
server.available() not working, not responding (specifically with port 21).
This blocked port 21? Port 21 is restricted? I not have idea.
this case: How I can unlock and use this port?
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
// User configurable variables
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte useDhcp = true;
IPAddress deviceIp (192, 168, 1, 177); // Only if useDhcp is false
IPAddress gatewayIp(192, 168, 1, 254); // Only if useDhcp is false
IPAddress dnsIp (192, 168, 1, 254); // Only if useDhcp is false
IPAddress subnet (255, 255, 255, 0); // Only if useDhcp is false
unsigned int serverPort = 21;
EthernetServer server(serverPort); // Declare server object
void setup()
{
Serial.begin(9600);
// disable w5100 SPI while setting up SD
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);
if(SD.begin(4) == 0) // set up SD
Serial.println("SD failed");
else
Serial.println("SD ok");
// Start network
if(useDhcp)
{ Ethernet.begin(mac); }
else
{ Ethernet.begin(mac, deviceIp, dnsIp, gatewayIp, subnet); }
digitalWrite(10,HIGH); // disable w5100 SPI
delay(1000); // takes a second for the w5100 to get ready
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
Serial.println(Ethernet.subnetMask());
Serial.println(Ethernet.gatewayIP());
Serial.println(Ethernet.dnsServerIP());
Serial.println("Setup done"); // rest of your setup
}
void loop()
{
if (server.available())
Serial.print("AVAL");
// if an incoming client connects, there will be bytes available to read:
EthernetClient client = server.available();
if (client == true) {
Serial.println("1 client !!!");
// read bytes from the incoming client and write them back
// to any clients connected to the server:
// server.write(client.read());
Serial.println(client.read());
}
else
{ Serial.print("z"); }
delay(800);
}
FTP requires two connections. One command and one data. I don't have a FTP server yet, but I do have a FTP client example in the playground. http://playground.arduino.cc/Code/FTP
edit: Don't use this. It causes an upload fail on many versions of the Mega2560 bootloader.
What software are you using to test the connection? Don't use a web browser. IE and Chrome will not open a connection to port 21. I use PuTTY.
I use port 21 and RAW. Set "close window on exit" to never so you can see the response.
IE and Chrome with 192.168.1.95:21
the simple C:\WINDOWS\system32\ftp.exe
and the FileZilla, now the psftp.exe.
of course the client software, NOT receive a response,
The sketch server response, yet.
But the client status is "connected",
this for a short time (exactly 60 seconds)
then "connection closed by remote host".
... and during that time,
function server.available() with absolutely omission of the connection of the client.
This occurs here, with my PC, Arduino, LAN, etc.,
I wonder if the function server.available(), responds appropriately in other circumstances using port 21.
I think that is part of bootloader,
I also think that: bootloader controls the ping responses.
On this, also would like to know how to control the ping responses.
To enable and disable ping replies,
But maybe this should be another forum thread.
My first attempt and then GOOL !!!
client detected !!!
Now, yet:
I have no idea what is the difference between ftp.exe and PuTTy.
The fact is that work differently,
and client PuTTY is detected by function server.available()
I have no idea what is the difference between ftp.exe and PuTTy.
The fact is that work differently,
and client PuTTY is detected by function server.available()
That is what I was saying. HTTP and FTP are different responses from the server. You can't put a HTTP server on a FTP port, then use a FTP program. You must use a RAW TCP type connection.
so,
if Ethernet.h and EthernetServer.h libraries are http-raw
my powelfull ftp server need "raw special client".
this is not what I want. I like work with standart ftp client.
Then I need other library to develop the FTP server.
Is this correct?
It is clear that I have no business idea,
but I want to do everything possible.
I appreciate any related information.
+++
I think this is Gordian Knot,
I suspect that begins in IPAddress.h,
UDP and RAW
... perhaps, a small modification ...
I do not know
the standard Arduino Ethernet library does not include something...
then use other one library ?
Now my question is: Which is best?
SurferTim:
That is what I was saying. HTTP and FTP are different responses from the server. You can't put a HTTP server on a FTP port, then use a FTP program. You must use a RAW TCP type connection.
I'm puzzled about what is going on here. It's clear this is on the right lines because changing the client has changed the behaviour, but according the the evidence given it shouldn't have made any difference - the problem described was that the server did not see any incoming connect request. Unless/until the TCP connection has been established it is irrelevant what application protocol is carried over it. The only explanation I can think of is that the description of the symptoms was inaccurate and in fact we were successfully establishing the TCP connection and then failing at some later step in the process.
It's clear this is on the right lines because changing the client has changed the behaviour, but according the the evidence given it shouldn't have made any difference - the problem described was that the server did not see any incoming connect request.
It did not receive a connection request because IE and Chrome do not allow any type of port 21 connection. Chrome displays the message "unsafe port" and does not attempt to establish a connection. Try it!
edit: You would have the same problem with a SMTP server. The client does not send a request. The server sends a "hello" first. Then the SMTP client responds to that hello. In this case, you do not show a connection until the client sends something. But the client will not send anything until the server sends a "hello". But you are not sending a "hello". Deadlock.
If you want to test this, fire up PuTTY and connect to the Arduino with port 21 and RAW mode. When it connects, don't enter anything. Check the Arduino. No connection. Now type "GET / HTTP/1.0" and press the enter key only once. Now you will get a "connection" message on the arduino, but it will not send a response until you press the enter key again.
SurferTim:
IE and Chrome do not allow any type of port 21 connection. Chrome displays the message "unsafe port" and does not attempt to establish a connection. Try it!
I've not noticed that behaviour before - but then, I don't tend to use a browser as a generic TCP client, because it isn't one. It seems happy enough using the FTP protocol on that port. However, it'd be far better to use a proper FTP client for testing (or even roll your own using telnet) so that you have full control over what happens. The good news is that none of this affects the server side code and is easily surmountable by using the right client.
Take a look at this code: http://playground.arduino.cc/Code/FTP
The first thing it does after the connection is established is wait for the FTP server to send a "hello". I would guess that the connection is not showing as established because that particular code is not sending the hello. The web browser may actually establish the connection to the ethernet shield, but when it does not receive a "hello" from the Arduino, then you get the unsafe port message. I have not checked the network packets.
edit: That is why I posted this warning in reply #9:
Don't mix protocols. The server response for a FTP connection is different than a HTTP connection.
I thought that the symptoms were that the Arduino wasn't seeing the incoming TCP connection at all, but I could be wrong. I wholeheartedly agree with your warning about using the wrong client for the protocol you're using.
I used PuTTY to test this stuff. It works just like I am telling you. The w5100 does not indicate "connected" on a socket until it has something in the rx buffer. You can connect, and the shield shows nothing. Send that one GET line to put something in the rx buffer, and suddenly you are connected.
If that is not the way it turns out for you, I would like to know that.