Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

TCP-IP over GPRS with Modbus

TCP-IP over GPRS with Modbus

TCP-IP over GPRS with Modbus

I am working to a project involving a GSM/GPRS module which role it is to connect clients with some devices over the internet using TCP-IP and Modbus protocol. Now I am studying the TCP connecting scheme.
As far as I understood , the GSM network automatically close a TCP connection if there is not any traffic on it for some time.
I want to detect and maintain TCP connection as reliable as possible. Also to detect half-open connections.
The connection procedure is as follows: my GSM module acts as a server, so it opens a socket on port 502 and wait for clients to read data. The client can read data periodically at 3 minutes or longer.
When a client connects with my module , it requests for some data, the module sends the requested data and wait for other requests, and keeps the connection open. Now if the connection gets broken for other reasons (due to power failures, GSM network etc) the client needs to be able to connect with the module again. The module must detect broken connection and must act so the client can reconnect to it again
In order to detect broken connection the module send periodically some dummy data to the client and check if that data was received by the client. If not, the tcp connection must be re-established.
The question is: how to interpret this "re-establishment" of the connection?
1. Should I close the current TCP connection, and open a new one, meaning listening to port 502 again?
2. Should I close the current TCP connection and trying to connect to the port and ip of the client as provided from the last valid TCP connection?

The point is that the module must be available as soon as possible to answer to client's requests; that it is why I need the TCP connection to be functional as soon as possible.

PS. The module supports just AT commands ( Quectel M95 module) so I don't have access to all functionalities of the TCP stack.
Thank you.
(I am new in TCP stack so I may have used technical terms with improper meaning)

RE: TCP-IP over GPRS with Modbus

The Modbus TCP client will handle establishment of the sockets.
The Modbus TCP server (your end device) should handle closing the socket should it become hung.
The client will initiate a poll of the end device (server) which establishes the socket on port 502. Should the socket close, the client will reestablish the socket on the next poll. It should be inherent in the client Modbus TCP driver.
As a Modbus TCP server, your device will be listening on port 502. Should a socket become hung, there should be a timer set in the server to close the socket should no data be received for X number of seconds. This should be a setting/function in the server.
Given that the Quectel M95 is just the transport, I do not think it would have any TCP control.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close