This module provides a counter part of QLocalServer and QLocalSocket. It is designed for implementing core logic layer by Golang behind Qt GUI.
As described in Qt's document, it uses Unix domain socket on POSIX systems and Named Pipe on Windows.
localsocket.LocalSocket
It implements
net.Conn
andio.Reader
andio.Writer
interface.Read(data []byte) (int, error)
Write(data []byte) (int, error)
Close() error
LocalAddr() net.Addr
RemoteAddr() net.Addr
SetDeadline(t time.Time) error
SetReadDeadline(t time.Time) error
SetWriteDeadline(t time.Time) error
localsocket.NewLocalSocket(address string) (*LocalSocket, error)
It connects via Unix Domain Socket at
${TMP}/<address>
on POSIX, or Named Pipe at\\.\pipe\<address>
on Windows .localsocket.NewLocalServer(address string) *LocalServer
Listen() error
Creates Unix Domain Socket at
${TMP}/<address>
on POSIX, or Named Pipe at\\.\pipe\<address>
on Windows and start waiting client.ListenAndServe() error
It is similar to
Listen()
, but blocks execution untilClose()
is called.SetOnConnectionCallback(callback func(socket *LocalSocket))
Registers callback function that is called when new client connects.
Close()
Closes connection.
Path() string
Returns actual path to Unix Domain Socket or Named Pipe.