Go Down

Topic: EthernetServer (TCP) for more than one connection? (Read 686 times) previous topic - next topic

Codeman

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
Perl is the only language that looks the same before and after RSA encryption.

PaulS

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.

Codeman

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
Perl is the only language that looks the same before and after RSA encryption.

PaulS

Quote
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?

SurferTim

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.  :)

Codeman

PaulS, SurferTim,

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

Quote
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 http://forum.rocrail.net/viewtopic.php?t=4583 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

 
Perl is the only language that looks the same before and after RSA encryption.

Go Up