proxy.golang.org : github.com/xaionaro-go/goautosocket
The GAS library provides auto-reconnecting TCP sockets in a tiny, fully tested, thread-safe API. The `TCPClient` struct embeds a `net.TCPConn` and overrides its `Read()` and `Write()` methods, making it entirely compatible with the `net.Conn` interface and the rest of the `net` package. This means you should be able to use this library by just replacing `net.Dial` with `gas.Dial` in your code. GAS uses the `atomic` package to synchronize reconnections between multiple goroutines; it doesn't add any extra locking upon the standard `net.TCPConn` API, except to protect its configuration from races. Hence, you should always use the `TCPClient.Set*` methods *before* you actually start doing any I/O. To test the library, you can run a local TCP server with: and run this code: Then try to kill and reboot your server, the client will automatically reconnect and start sending messages again; unless it has reached its retry limit.
Registry
-
Source
- Documentation
- JSON
- codemeta.json
purl: pkg:golang/github.com/xaionaro-go/goautosocket
License: MIT
Latest release: 3 days ago
Namespace: github.com/xaionaro-go
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 3 days ago