Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kilemonn/go-ipc
An inter-process communication library written in Golang.
https://github.com/kilemonn/go-ipc
go golang inter-process-communication linux socket unix-socket windows
Last synced: about 7 hours ago
JSON representation
An inter-process communication library written in Golang.
- Host: GitHub
- URL: https://github.com/kilemonn/go-ipc
- Owner: Kilemonn
- License: apache-2.0
- Created: 2024-11-02T11:30:50.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-04T02:20:15.000Z (about 2 months ago)
- Last Synced: 2024-12-22T05:14:25.945Z (about 7 hours ago)
- Topics: go, golang, inter-process-communication, linux, socket, unix-socket, windows
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-ipc
An inter-process communication library written in Golang. Using "unix" sockets to support interprocess communication. **This also works on Windows!**## Get started
You can add this project as a dependency using:
> go get github.com/Kilemonn/go-ipc
Once added you can setup connections as per below (error handling removed for brevity):
```go
package mainimport (
"time""github.com/Kilemonn/go-ipc/client"
"github.com/Kilemonn/go-ipc/server"
)func main() {
ipcChannelName := "readme-example"
svr, _ := server.NewIPCServer(ipcChannelName, nil)
defer svr.Close()client, err := client.NewIPCClient(ipcChannelName)
defer client.Close()accepted, err := svr.Accept(time.Millisecond * 1000)
defer accepted.Close()content := "some-data"
_, err := client.Write([]byte(content))b := make([]byte, len(content))
_, err = accepted.Read(b)if content == string(b) {
fmt.Println("Sent and read is the same!")
}
}
```## Notes
- The `IPCClient` implements the `io.ReadWriterCloser` interface and provides a property to set read timeouts instead of remaining blocking.
- This is aimed to be a very primative and simple implementation for now, other settings and customisability can be built upon what is currently implemented. However feel free to request any features that would be useful.