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

Philipp Burch phip at hb9etc.ch
Wed Nov 26 22:30:03 CET 2014


Heyho!

On 26.11.2014 13:03, Philipp Burch wrote:
> [...]
> 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.
> 
> [...]

Those proposed changes are now committed as r5914 in the devnut_tiva
branch. It should not alter the behaviour of any existing code (except
for a single additional nesting level in the
NutTcpStatePassiveOpenEvent() function).
Please feel free to comment on the change and run whatever tests you
have with it :)


devnut_tiva$ svn commit -m 'Implemented functions to set TCP sockets to
listening state without blocking. This makes it possible to have a
socket listen for incoming connections while performing other tasks in a
single thread. The change basically splits NutTcpStatePassiveOpenEvent()
into NutTcpStatePassiveOpenEventNonblock() (first part) and
NutTcpStatePassiveEventWait() (second part). The respective user API
functions are NutTcpAcceptNonblock() and NutTcpAcceptWait().'
nut/include/netinet/tcp_fsm.h nut/include/pro/ftpd.h
nut/include/sys/socket.h nut/net/tcpsm.c nut/net/tcpsock.c
Sending        nut/include/netinet/tcp_fsm.h
Sending        nut/include/pro/ftpd.h
Sending        nut/include/sys/socket.h
Sending        nut/net/tcpsm.c
Sending        nut/net/tcpsock.c
Transmitting file data .....
Committed revision 5914.


Thanks and best regards,
Philipp



More information about the En-Nut-Discussion mailing list