Handling of SRCP connections (client side)

Moderator: Moderators

Handling of SRCP connections (client side)

Postby Codeman » 17.01.2013, 13:55

Hi all,

I am writing code for Arduino which I want to use as a SRCP-Central-Station.
The (MM2) signal generation works already but I have some trouble in implementing the SRCP server code for the Ethernet shield.

My question:
The SRCP specification seems not to need a persistant TCP connection, right?
How does RocRail handle this? What happens if the server closes the connection after each command? Does RocRail autoconnect again for the next command?

Regards, Holger

Postby LDG » 17.01.2013, 14:37

Hello Holger,

have you read the SRCP specification (0.84) and understood what is happening when establishing a new session (handshake for command or information mode, session identifiers,...) ?

Sessions are usually closed by the client that opened that session. The server may close session if it is shutting down. "Normal" sessions are not closed by the server after each command. The overhead (handshake at session start up vs data) would be too big).

Have a look whats going on when a SRCP client connects to the original server. Your server should behave (almost :roll: ) like the original server. That's what I implemented, when Rocrail acts as SRCP server.

When Rocrail acts as a client (Rob's implementation) it will try to automatically reconnect (-> establish a new connection) when the the session is missing/lost for most of the commands.

Just check your SRCP server implementation with the usual/official/"well known" clients. I guess most of them open a session at start up and do not automatically reconnect if the session is closed by the server.

You may ask your questions concerning srcp basics in the newsgroup "de.rec.modelle.bahn" . That is the official srcp discussion media :)

Site Admin


Postby Codeman » 17.01.2013, 15:28


thanks for your hints. I was a little bit confused after reading the SRCP specification. I thaught that the server can close the session, too. But I see that there will be much problems when doing so.

The original problem is that the Arduino Ethernet library cannot distinguish between several TCP sessions. Also it seems that the Ethernet shield can handle four TCP connections there is no code for supporting this.

Before implementing my own server I will have to try to get the Arduino Ethernet library to get to work with four sessions...

Thanks a lot!

Regards, Holger

Return to srcp