There are probably several steps to do this.
One: gps devices first access the Internet through some means (either dial-up or wifi). . . . )
Two: the gps device applies to connect to the server (the machine running the program). You can use the domain name or IP to find your server.
Three: the server accepts the connection.
Four: You use this gps device to make an appointment in advance. The way you communicate.
What is commonly used is probably, ask and answer. You can send a request command to the device through tcp connection, and the device will reply to you after receiving it. Then all you have to do is analyze the reply instruction.
How to monitor connections and how to send and receive connections. This book makes it very clear.