[En-Nut-Discussion] Asynchronous listening sockets (was Re: FTP server support)

Philipp Burch phip at hb9etc.ch
Wed Nov 26 13:03:19 CET 2014


Hello,

I'm currently thinking about some options to implement/fix passive FTP
mode (see cite below). This involves creating a listening socket for the
data connection when the client asks for passive mode without
immediately getting a connection. That could be done by using another
thread which just opens a socket and calls NutTcpAccept(), thereby
blocking until the client establishes a connection. This would work for
sure, but wasting another thread just for this purpose is probably
somewhat overkill.
My proposal for this task would be to extend the socket API by a
function NutTcpAcceptNonblock() or something like this, which performs
the same operations on the socket as NutTcpAccept(), but without the
final NutEventWait() in NutTcpStatePassiveOpenEvent(). Another function,
probably named NutTcpAcceptWait() could then implement the actual
waiting, which the user may call when the connection is actually needed.

With these changes, the passive FTP mode could be implemented quite
easily. NutFtpProcessPassive() would then call NutTcpAcceptNonblock() on
the data socket to make it accept connections and then ("in parallel")
send the response to the client. The client will issue the next command,
maybe ls or put or whatever. This results in a call to
NutFtpDataConnect(), which would then simply call NutTcpAcceptWait() and
afterwards return the data socket. NutFtpDataClose() would then need to
be aware of the passive mode as well and avoid closing the socket in
that case.

What do you think about this solution? I know that messing with the TCP
API shouldn't be done without reason, but I guess it would be beneficial
in this case.

Cheers,
Philipp

On 25.11.2014 15:08, Ole Reinhardt wrote:
> Hi Philipp,
> 
> Am 25.11.2014 11:37, schrieb Philipp Burch:
>> to passive mode, the connection is reset by the board. When using
>> FireFTP (an FTP plugin for Firefox), the connection is extremely
>> unstable, directory listings may or may not work. File transmission can
>> be started if in passive mode (?!), but stall after 21'440 bytes during
>> upload. Downloads seem to work.
> 
> Unfortunately passive mode is kompletely broken in the FTP
> implementation. Passive mode needs a listening socket to be opened right
> in the moment, when the port number has been negotiated. Unfortunately
> our passive mode implementation openes the listening socket at some
> later (and wrong) stage?!?
> 
> I just asked on the mailinglist some time ago, if someone just
> implemented a working passive mode, but it looks like nobody had...
> 
> Unfortunately I have not had yet the time to fix it by myself.
> 
> Any help here is very wellcome!
> 
> Best regards,
> 
> Ole
> 
> 


More information about the En-Nut-Discussion mailing list