











{"author":"Faiq Najib Al-Aziz","body":"\nImagine 500 GPS trackers connected to your server at once. Each sends location data every 10-30 seconds, while some send only a heartbeat when idle. Connections can stay open for hours, drop without notice, or deliver data in fragments. Ehem, busy place.\n\nIf you are used to HTTP APIs, remember that TCP itself has no request-response structure. The listener just receives a stream of bytes, and your application has to make sense of it.\n\nIn [Part 1](/en/writing/2026/memahami-gps-protocol/) we covered how devices communicate through persistent TCP connections and binary packets governed by vendor-specific rules. Now we build a TCP listener in Go to accept those connections.\n\nThe pattern is the same one handling hundreds of devices in my production systems. It uses only Go's standard library, no frameworks.\n\n## What We Are Building Today\n\nThe goal is a small program that:\n\n1. Accepts multiple connections concurrently, one goroutine per connection\n2. Reassembles raw TCP streams into valid **GT06 frames** (this is where most people trip up)\n3. Drops zombie connections that went silent without properly closing\n4. Shuts down cleanly during deploys (graceful shutdown)\n\nWe will not decode packet payloads, store data in a database, or add a message queue yet. Login packets, location packets, and valid ACK responses require CRC-ITU checksums; that is covered in [Part 3](/en/writing/2026/decode-packet-gt06-teltonika/). The listener just accepts and assembles frames, and what happens after that can wait.\n\n## A Basic TCP Server\n\nStart with a basic server:\n\n```go\nlistener, err := net.Listen(\"tcp\", \":5094\")\nif err != nil {\n    log.Fatal(err)\n}\ndefer listener.Close()\n\nfor {\n    conn, err := listener.Accept()\n    if err != nil {\n        log.Printf(\"accept error: %v\", err)\n        continue\n    }\n    go handleConnection(conn)\n}\n```\n\n`net.Listen` opens the port, and the `Accept` loop waits for connections. Each one runs in its own goroutine. **Goroutines are cheap**: the initial stack is a few kilobytes, compared with the megabytes of an OS thread. So the \"one goroutine per connection\" model stays lightweight when connections pile up.\n\nFor a GPS listener, I do not recommend HTTP: per-request header overhead, short-lived connections, and HTTP parsing that is useless for raw binary packets. Your tracker will not send a `Content-Type` header either, hehe.\n\n## The First Pitfall: TCP Is a Stream, Not a Message Bus\n\nThis is the main difference between handling GPS TCP traffic and serving HTTP requests.\n\nHTTP code gets used to a guarantee: one request equals one self-contained packet. In TCP, **there is no such guarantee**. A call to `conn.Read(buf)` merely says: \"give me whatever bytes are there right now.\" That means:\n\n- **A frame can arrive fragmented.** A device sends a 70-byte frame, but your first `Read` only pulls 40 bytes; the remaining 30 bytes arrive 200 ms later.\n- **Multiple frames can stick together.** If a device sends two frames back-to-back, a single `Read` may grab both at once.\n- **Garbage bytes happen.** Freshly booted trackers sometimes spew junk right before their first valid packet.\n\nIf you treat each `Read` result as a complete message, packet decoding can fail randomly, and it is easy to blame the device. (I did. For a long time.)\n\nThe solution is **explicit framing**. We use `bufio.Reader` to read the stream, find the GT06 start bits (`0x78 0x78`), read the length byte, and then pull the rest of the frame:\n\n```go\n// readFrame extracts a single GT06 frame from the stream:\n//\n//\t78 78 | len | protocol | data | serial | crc | 0D 0A\nfunc readFrame(r *bufio.Reader) ([]byte, error) {\n\t// 1. Synchronize: discard bytes until we locate start bits 78 78\n\tfor {\n\t\tb, err := r.ReadByte()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif b != 0x78 {\n\t\t\tcontinue // Garbage byte: skip it\n\t\t}\n\t\tb2, err := r.ReadByte()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif b2 != 0x78 {\n\t\t\tcontinue // Isolated 0x78, not a start delimiter: keep scanning\n\t\t}\n\t\tbreak\n\t}\n\n\tframe := []byte{0x78, 0x78}\n\n\t// 2. Read length (1 byte: count of bytes from protocol through CRC, inclusive)\n\tlenByte, err := r.ReadByte()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tframe = append(frame, lenByte)\n\n\t// 3. Pull the remaining frame: len + 2 bytes (payload + CRC + stop bits 0D 0A)\n\trest := make([]byte, int(lenByte)+2)\n\tif _, err := io.ReadFull(r, rest); err != nil {\n\t\treturn nil, err\n\t}\n\tframe = append(frame, rest...)\n\n\t// 4. Validate stop bits\n\tif frame[len(frame)-2] != 0x0D || frame[len(frame)-1] != 0x0A {\n\t\treturn nil, fmt.Errorf(\"invalid stop bits: %X\", frame[len(frame)-2:])\n\t}\n\treturn frame, nil\n}\n```\n\n`io.ReadFull` **waits until the destination buffer is full**, so bytes that arrive in fragments still end up as one frame. `bufio.Reader` keeps unused bytes buffered, so when two frames arrive together, the second one is still available for the next read.\n\nRemember the framing rule from Part 1: the `len` byte covers everything from the protocol number up to the CRC, inclusive. That is why after reading `lenByte`, we read exactly `len + 2` more bytes (payload + CRC + 2 stop bytes).\n\n## handleConnection: The Frame Processing Loop\n\nWith framing in place, the handler just reads frames from each connection:\n\n```go\nfunc handleConnection(ctx context.Context, conn net.Conn) {\n\tdefer conn.Close()\n\tremote := conn.RemoteAddr().String()\n\tlog.Printf(\"connected: %s\", remote)\n\n\treader := bufio.NewReader(conn)\n\tfor {\n\t\tconn.SetReadDeadline(time.Now().Add(readTimeout))\n\n\t\tframe, err := readFrame(reader)\n\t\tif err != nil {\n\t\t\tif errors.Is(err, io.EOF) {\n\t\t\t\tlog.Printf(\"disconnected: %s\", remote)\n\t\t\t} else if ctx.Err() == nil {\n\t\t\t\tlog.Printf(\"read error (%s): %v\", remote, err)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tlog.Printf(\"frame from %s: %X (%d bytes)\", remote, frame, len(frame))\n\t\t// TODO part 3: decode payload + send valid ACK response (requires CRC-ITU)\n\t}\n}\n```\n\nFor now, the handler only logs each frame in hex. In Part 3, we replace the `TODO` with a decoder.\n\n## Zombie Sockets and Read Deadlines\n\nThe `conn.SetReadDeadline(...)` call controls how long the handler waits for data.\n\nGPS trackers on cellular networks can drop without sending a TCP closing packet (`FIN`), for example when the signal drops, a battery is pulled, or a carrier resets the connection. The server may then keep sockets that **look alive but are completely dead**. Left alone, these pile up and eat file descriptors.\n\nWith `SetReadDeadline`, if no bytes arrive before the deadline, `Read` returns an I/O timeout error. The handler exits and closes the connection.\n\n**Your read deadline must exceed the device's idle heartbeat interval.** As in Part 1, stationary devices send a heartbeat every 2 to 5 minutes. A 90-second deadline would disconnect a healthy device that is just sitting idle. So I set it to:\n\n```go\n// Must exceed device heartbeat interval (GT06 devices send heartbeats every 2-5 minutes when idle)\nvar readTimeout = 10 * time.Minute\n```\n\nThe deadline resets after every frame, so active devices remain connected.\n\n## Exiting Gracefully: Graceful Shutdown\n\nProduction listeners may restart during deploys, scaling, or maintenance. When a container or system stops, the OS usually sends a `SIGTERM` signal and gives the process time to shut down before killing it.\n\nWe use that time to close the listener, close active connections, and wait for the handler goroutines to finish before exiting.\n\n```go\nfunc main() {\n\tctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)\n\tdefer stop()\n\n\tlistener, err := net.Listen(\"tcp\", \":5094\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tvar wg sync.WaitGroup\n\tconns := newConnTracker()\n\n\t// Shutdown supervisor: close listener and terminate active sockets upon receiving a signal\n\tgo func() {\n\t\t\u003c-ctx.Done()\n\t\tlog.Println(\"shutting down: closing listener and active connections\")\n\t\tlistener.Close()\n\t\tconns.CloseAll()\n\t}()\n\n\tlog.Println(\"listening on :5094\")\n\tfor {\n\t\tconn, err := listener.Accept()\n\t\tif err != nil {\n\t\t\tif ctx.Err() != nil {\n\t\t\t\tbreak // Shutdown initiated: break out of accept loop\n\t\t\t}\n\t\t\tlog.Printf(\"accept error: %v\", err)\n\t\t\tcontinue\n\t\t}\n\t\twg.Add(1)\n\t\tconns.Add(conn)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tdefer conns.Remove(conn)\n\t\t\thandleConnection(ctx, conn)\n\t\t}()\n\t}\n\n\twg.Wait()\n\tlog.Println(\"bye\")\n}\n```\n\n`connTracker` stores active connections so they can all be closed at once:\n\n```go\ntype connTracker struct {\n\tmu    sync.Mutex\n\tconns map[net.Conn]struct{}\n}\n\nfunc newConnTracker() *connTracker {\n\treturn \u0026connTracker{conns: make(map[net.Conn]struct{})}\n}\n\nfunc (t *connTracker) Add(c net.Conn) {\n\tt.mu.Lock()\n\tt.conns[c] = struct{}{}\n\tt.mu.Unlock()\n}\n\nfunc (t *connTracker) Remove(c net.Conn) {\n\tt.mu.Lock()\n\tdelete(t.conns, c)\n\tt.mu.Unlock()\n}\n\nfunc (t *connTracker) CloseAll() {\n\tt.mu.Lock()\n\tdefer t.mu.Unlock()\n\tfor c := range t.conns {\n\t\tc.Close()\n\t}\n}\n```\n\n`signal.NotifyContext` turns `SIGTERM` or Ctrl+C into `ctx.Done()`. The cleanup goroutine closes the listener, causing `Accept` to return an error and end the main loop, then closes active connections. `sync.WaitGroup` waits for all handlers to finish before `main` exits.\n\n## Testing Without Real Hardware\n\nYou can try this without a physical tracker. Bash's `/dev/tcp` support is enough to send data as if it came from a GT06 tracker:\n\n```bash\nexec 3\u003c\u003e/dev/tcp/127.0.0.1/5094\nprintf '\\x78\\x78\\x0d\\x01\\x01\\x23\\x45\\x67\\x89\\x01\\x23\\x45\\x00\\x01\\x8c\\xdd\\x0d\\x0a' \u003e\u00263\n```\n\nThis is a GT06 login frame from the protocol datasheet, with terminal ID `123456789012345`, discussed in [Part 1](/en/writing/2026/memahami-gps-protocol/). I tested the program over loopback on my laptop with these scenarios:\n\n| Scenario | Result |\n| --- | --- |\n| Complete single frame | Extracted 1 frame, 18 bytes ✓ |\n| Frame split across two writes (second chunk sent 1 second later) | Successfully reassembled into a single frame ✓ |\n| Two frames combined into a single write | Correctly parsed as two separate frames ✓ |\n| Leading garbage bytes (`FF DE AD`) preceding valid frame | Discarded garbage bytes, frame read cleanly ✓ |\n| 20 concurrent connections transmitting simultaneously | 20 frames parsed without race conditions ✓ |\n| `SIGTERM` issued while connections are active | Listener and sockets closed, clean exit ✓ |\n\nThis is the log output from startup through shutdown:\n\n```text\n2026/09/12 20:25:31 listening on :5094\n2026/09/12 20:25:32 connected: 127.0.0.1:45870\n2026/09/12 20:25:32 frame from 127.0.0.1:45870: 78780D01012345678901234500018CDD0D0A (18 bytes)\n2026/09/12 20:25:33 shutting down: closing listener and active connections\n2026/09/12 20:25:33 bye\n```\n\n## Notes Before Moving On\n\n- **One goroutine per connection** is the standard pattern for Go TCP servers. Goroutines are light, so one goroutine per connection stays reasonable. The real limit depends on memory, file descriptors, and workload, so measure before quoting a number.\n- **TCP is a stream.** One `Read` call does not equal one packet. Custom framing (start bits + length + `io.ReadFull`) is the only reliable way to read binary protocols.\n- **Set deadlines higher than heartbeat intervals.** `SetReadDeadline` cleans up dead sockets, but a short timeout will disconnect healthy, idle devices.\n- **Close connections during shutdown.** `SIGTERM` gives the process a chance to close the listener and active sockets cleanly.\n\nThe listener now captures and separates frames, but does not parse payloads or respond with ACK packets. Without an ACK, real trackers assume the server is not responding and keep retransmitting old packets. Both tasks need CRC-ITU checksums and an understanding of GT06 payloads.\n\n## What's Next\n\nThis post is part of the **Building a GPS Backend from Scratch** series.\n\n- Previous: [Part 1: Understanding GPS Protocols](/en/writing/2026/memahami-gps-protocol/)\n- Next: [Part 3: Decoding Packets: GT06 and Teltonika Protocols](/en/writing/2026/decode-packet-gt06-teltonika/). There we write the real packet decoder: parse login packets and coordinates, calculate CRCs, and send valid ACKs.\n\n## Connect\n\nIf you have questions about this GPS listener, reach out via [Contact](/contact/). You can also subscribe via [RSS](/writing/index.xml) to follow the next article.\n","body_clean":"Imagine 500 GPS trackers connected to your server at once. Each sends location data every 10-30 seconds, while some send only a heartbeat when idle. Connections can stay open for hours, drop without notice, or deliver data in fragments. Ehem, busy place.\nIf you are used to HTTP APIs, remember that TCP itself has no request-response structure. The listener just receives a stream of bytes, and your application has to make sense of it.\nIn Part 1 we covered how devices communicate through persistent TCP connections and binary packets governed by vendor-specific rules. Now we build a TCP listener in Go to accept those connections.\nThe pattern is the same one handling hundreds of devices in my production systems. It uses only Go\u0026rsquo;s standard library, no frameworks.\nWhat We Are Building Today #The goal is a small program that:\nAccepts multiple connections concurrently, one goroutine per connection Reassembles raw TCP streams into valid GT06 frames (this is where most people trip up) Drops zombie connections that went silent without properly closing Shuts down cleanly during deploys (graceful shutdown) We will not decode packet payloads, store data in a database, or add a message queue yet. Login packets, location packets, and valid ACK responses require CRC-ITU checksums; that is covered in Part 3. The listener just accepts and assembles frames, and what happens after that can wait.\nA Basic TCP Server #Start with a basic server:\nlistener, err := net.Listen(\u0026#34;tcp\u0026#34;, \u0026#34;:5094\u0026#34;) if err != nil { log.Fatal(err) } defer listener.Close() for { conn, err := listener.Accept() if err != nil { log.Printf(\u0026#34;accept error: %v\u0026#34;, err) continue } go handleConnection(conn) } net.Listen opens the port, and the Accept loop waits for connections. Each one runs in its own goroutine. Goroutines are cheap: the initial stack is a few kilobytes, compared with the megabytes of an OS thread. So the \u0026ldquo;one goroutine per connection\u0026rdquo; model stays lightweight when connections pile up.\nFor a GPS listener, I do not recommend HTTP: per-request header overhead, short-lived connections, and HTTP parsing that is useless for raw binary packets. Your tracker will not send a Content-Type header either, hehe.\nThe First Pitfall: TCP Is a Stream, Not a Message Bus #This is the main difference between handling GPS TCP traffic and serving HTTP requests.\nHTTP code gets used to a guarantee: one request equals one self-contained packet. In TCP, there is no such guarantee. A call to conn.Read(buf) merely says: \u0026ldquo;give me whatever bytes are there right now.\u0026rdquo; That means:\nA frame can arrive fragmented. A device sends a 70-byte frame, but your first Read only pulls 40 bytes; the remaining 30 bytes arrive 200 ms later. Multiple frames can stick together. If a device sends two frames back-to-back, a single Read may grab both at once. Garbage bytes happen. Freshly booted trackers sometimes spew junk right before their first valid packet. If you treat each Read result as a complete message, packet decoding can fail randomly, and it is easy to blame the device. (I did. For a long time.)\nThe solution is explicit framing. We use bufio.Reader to read the stream, find the GT06 start bits (0x78 0x78), read the length byte, and then pull the rest of the frame:\n// readFrame extracts a single GT06 frame from the stream: // //\t78 78 | len | protocol | data | serial | crc | 0D 0A func readFrame(r *bufio.Reader) ([]byte, error) { // 1. Synchronize: discard bytes until we locate start bits 78 78 for { b, err := r.ReadByte() if err != nil { return nil, err } if b != 0x78 { continue // Garbage byte: skip it } b2, err := r.ReadByte() if err != nil { return nil, err } if b2 != 0x78 { continue // Isolated 0x78, not a start delimiter: keep scanning } break } frame := []byte{0x78, 0x78} // 2. Read length (1 byte: count of bytes from protocol through CRC, inclusive) lenByte, err := r.ReadByte() if err != nil { return nil, err } frame = append(frame, lenByte) // 3. Pull the remaining frame: len + 2 bytes (payload + CRC + stop bits 0D 0A) rest := make([]byte, int(lenByte)+2) if _, err := io.ReadFull(r, rest); err != nil { return nil, err } frame = append(frame, rest...) // 4. Validate stop bits if frame[len(frame)-2] != 0x0D || frame[len(frame)-1] != 0x0A { return nil, fmt.Errorf(\u0026#34;invalid stop bits: %X\u0026#34;, frame[len(frame)-2:]) } return frame, nil } io.ReadFull waits until the destination buffer is full, so bytes that arrive in fragments still end up as one frame. bufio.Reader keeps unused bytes buffered, so when two frames arrive together, the second one is still available for the next read.\nRemember the framing rule from Part 1: the len byte covers everything from the protocol number up to the CRC, inclusive. That is why after reading lenByte, we read exactly len + 2 more bytes (payload + CRC + 2 stop bytes).\nhandleConnection: The Frame Processing Loop #With framing in place, the handler just reads frames from each connection:\nfunc handleConnection(ctx context.Context, conn net.Conn) { defer conn.Close() remote := conn.RemoteAddr().String() log.Printf(\u0026#34;connected: %s\u0026#34;, remote) reader := bufio.NewReader(conn) for { conn.SetReadDeadline(time.Now().Add(readTimeout)) frame, err := readFrame(reader) if err != nil { if errors.Is(err, io.EOF) { log.Printf(\u0026#34;disconnected: %s\u0026#34;, remote) } else if ctx.Err() == nil { log.Printf(\u0026#34;read error (%s): %v\u0026#34;, remote, err) } return } log.Printf(\u0026#34;frame from %s: %X (%d bytes)\u0026#34;, remote, frame, len(frame)) // TODO part 3: decode payload + send valid ACK response (requires CRC-ITU) } } For now, the handler only logs each frame in hex. In Part 3, we replace the TODO with a decoder.\nZombie Sockets and Read Deadlines #The conn.SetReadDeadline(...) call controls how long the handler waits for data.\nGPS trackers on cellular networks can drop without sending a TCP closing packet (FIN), for example when the signal drops, a battery is pulled, or a carrier resets the connection. The server may then keep sockets that look alive but are completely dead. Left alone, these pile up and eat file descriptors.\nWith SetReadDeadline, if no bytes arrive before the deadline, Read returns an I/O timeout error. The handler exits and closes the connection.\nYour read deadline must exceed the device\u0026rsquo;s idle heartbeat interval. As in Part 1, stationary devices send a heartbeat every 2 to 5 minutes. A 90-second deadline would disconnect a healthy device that is just sitting idle. So I set it to:\n// Must exceed device heartbeat interval (GT06 devices send heartbeats every 2-5 minutes when idle) var readTimeout = 10 * time.Minute The deadline resets after every frame, so active devices remain connected.\nExiting Gracefully: Graceful Shutdown #Production listeners may restart during deploys, scaling, or maintenance. When a container or system stops, the OS usually sends a SIGTERM signal and gives the process time to shut down before killing it.\nWe use that time to close the listener, close active connections, and wait for the handler goroutines to finish before exiting.\nfunc main() { ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer stop() listener, err := net.Listen(\u0026#34;tcp\u0026#34;, \u0026#34;:5094\u0026#34;) if err != nil { log.Fatal(err) } var wg sync.WaitGroup conns := newConnTracker() // Shutdown supervisor: close listener and terminate active sockets upon receiving a signal go func() { \u0026lt;-ctx.Done() log.Println(\u0026#34;shutting down: closing listener and active connections\u0026#34;) listener.Close() conns.CloseAll() }() log.Println(\u0026#34;listening on :5094\u0026#34;) for { conn, err := listener.Accept() if err != nil { if ctx.Err() != nil { break // Shutdown initiated: break out of accept loop } log.Printf(\u0026#34;accept error: %v\u0026#34;, err) continue } wg.Add(1) conns.Add(conn) go func() { defer wg.Done() defer conns.Remove(conn) handleConnection(ctx, conn) }() } wg.Wait() log.Println(\u0026#34;bye\u0026#34;) } connTracker stores active connections so they can all be closed at once:\ntype connTracker struct { mu sync.Mutex conns map[net.Conn]struct{} } func newConnTracker() *connTracker { return \u0026amp;connTracker{conns: make(map[net.Conn]struct{})} } func (t *connTracker) Add(c net.Conn) { t.mu.Lock() t.conns[c] = struct{}{} t.mu.Unlock() } func (t *connTracker) Remove(c net.Conn) { t.mu.Lock() delete(t.conns, c) t.mu.Unlock() } func (t *connTracker) CloseAll() { t.mu.Lock() defer t.mu.Unlock() for c := range t.conns { c.Close() } } signal.NotifyContext turns SIGTERM or Ctrl+C into ctx.Done(). The cleanup goroutine closes the listener, causing Accept to return an error and end the main loop, then closes active connections. sync.WaitGroup waits for all handlers to finish before main exits.\nTesting Without Real Hardware #You can try this without a physical tracker. Bash\u0026rsquo;s /dev/tcp support is enough to send data as if it came from a GT06 tracker:\nexec 3\u0026lt;\u0026gt;/dev/tcp/127.0.0.1/5094 printf \u0026#39;\\x78\\x78\\x0d\\x01\\x01\\x23\\x45\\x67\\x89\\x01\\x23\\x45\\x00\\x01\\x8c\\xdd\\x0d\\x0a\u0026#39; \u0026gt;\u0026amp;3 This is a GT06 login frame from the protocol datasheet, with terminal ID 123456789012345, discussed in Part 1. I tested the program over loopback on my laptop with these scenarios:\nScenario Result Complete single frame Extracted 1 frame, 18 bytes ✓ Frame split across two writes (second chunk sent 1 second later) Successfully reassembled into a single frame ✓ Two frames combined into a single write Correctly parsed as two separate frames ✓ Leading garbage bytes (FF DE AD) preceding valid frame Discarded garbage bytes, frame read cleanly ✓ 20 concurrent connections transmitting simultaneously 20 frames parsed without race conditions ✓ SIGTERM issued while connections are active Listener and sockets closed, clean exit ✓ This is the log output from startup through shutdown:\n2026/09/12 20:25:31 listening on :5094 2026/09/12 20:25:32 connected: 127.0.0.1:45870 2026/09/12 20:25:32 frame from 127.0.0.1:45870: 78780D01012345678901234500018CDD0D0A (18 bytes) 2026/09/12 20:25:33 shutting down: closing listener and active connections 2026/09/12 20:25:33 bye Notes Before Moving On # One goroutine per connection is the standard pattern for Go TCP servers. Goroutines are light, so one goroutine per connection stays reasonable. The real limit depends on memory, file descriptors, and workload, so measure before quoting a number. TCP is a stream. One Read call does not equal one packet. Custom framing (start bits + length + io.ReadFull) is the only reliable way to read binary protocols. Set deadlines higher than heartbeat intervals. SetReadDeadline cleans up dead sockets, but a short timeout will disconnect healthy, idle devices. Close connections during shutdown. SIGTERM gives the process a chance to close the listener and active sockets cleanly. The listener now captures and separates frames, but does not parse payloads or respond with ACK packets. Without an ACK, real trackers assume the server is not responding and keep retransmitting old packets. Both tasks need CRC-ITU checksums and an understanding of GT06 payloads.\nWhat\u0026rsquo;s Next #This post is part of the Building a GPS Backend from Scratch series.\nPrevious: Part 1: Understanding GPS Protocols Next: Part 3: Decoding Packets: GT06 and Teltonika Protocols. There we write the real packet decoder: parse login packets and coordinates, calculate CRCs, and send valid ACKs. Connect #If you have questions about this GPS listener, reach out via Contact. You can also subscribe via RSS to follow the next article.\n","canonical":"https://najib.id/en/writing/2026/tcp-listener-gps-go/","description":"How to build a concurrent TCP server in Go to handle hundreds of GPS trackers: from net.Listen and binary packet framing on raw TCP streams to read deadlines and graceful shutdown.","language":"en","lastmod":"2026-11-11T23:31:00Z","publishedAt":"2026-09-22T00:00:00Z","readingTime":9,"section":"writing","series":"gps-backend-series","tags":["golang","gps","tcp","networking"],"title":"Building a TCP Listener for GPS Devices in Go","type":"writing","url":"https://najib.id/en/writing/2026/tcp-listener-gps-go/","wordCount":1782}
