EthernetServer (TCP) for more than one connection?

Hi all,

is it possible to write a server sketch where I can accept more than one connection via TCP? I have only found many (working) example for just one connection...

Thanks, Holger

Multiple connections at the same time?

The general practice is to deal with one connection at a time. Why do you want to do something different? The server should not be trying to maintain state, or to remember/know anything about the client. It seems that that would be necessary for processing more than one connection at a time to make any sense.

PaulS,

thanks for the fast answer!

I have a sketch for driving Maerklin-Motorola-II model locomotives. Now I want to add support for SRCP (http://srcpd.sourceforge.net/srcp/srcp-084.pdf), so I can create a SRCP central station. For this I have to allow 1+n clients. Clients can be programs or other Arduinos which can talk SRCP. SRCP is TCP based...

Regards, Holger

For this I have to allow 1+n clients.

Understood, but why do you (think you) need to deal with more than one at a time?

Is that protocol a persistent connection? It does not appear so. The w5100 will allow multiple connections (4), but the ethernet library services one at a time. It will service them pretty fast.

This is what your protocol specifies:
Open -> handshake -> data -> close
That looks like a standard web server
connect -> request -> response -> close

Very interesting application. :slight_smile:

PaulS, SurferTim,

perhaps it will work without persistant connections. The protocol definition doesn't specifiy something like that, right. But it also says:

The server MUST differentiate all client sessions internally

The big question is: How does the SRCP client software interprets this (like RocRail, Android SRCP client, ...). Perhaps I will try it with non-persistant connections and see what happens. If it will not work I have to think about it again (perhaps using a Raspberry with multithreaded server and connect the Arduino to the Rapsi with I2C).

The project can be found at https://sourceforge.net/projects/maerklino/. The current state is: The first version of Jan Weller is working (see Rocrail - Innovative Model Railroad Control System - Login but not very comfortable. I have done some changes but hadn't test them until now. Hopefully I can do this on weekend.

Thanks, Holger