[En-Nut-Discussion] Asynchronous listening sockets (was Re: FTP server support)
phip at hb9etc.ch
Wed Nov 26 22:30:03 CET 2014
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
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/sys/socket.h nut/net/tcpsm.c nut/net/tcpsock.c
Transmitting file data .....
Committed revision 5914.
Thanks and best regards,
More information about the En-Nut-Discussion