Pages: [1]   Go Down
Author Topic: EthernetServer (TCP) for more than one connection?  (Read 608 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 139
Posts: 5860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley
Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

 
Logged

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

Pages: [1]   Go Up
Jump to: