Skip to content

Commit ebe48b4

Browse files
committed
Documentation updates, method name change, and missing defer to the Listen constructor.
1 parent cf73425 commit ebe48b4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

qmp/socket.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,19 @@ func NewSocketMonitor(network, addr string, timeout time.Duration) (*SocketMonit
6868
return mon, nil
6969
}
7070

71-
// NewListeningSocketMonitor listens for a monitor socket connection from Qemu.
72-
// An error is returned if the connection fails to accept.
73-
func NewListeningSocketMonitor(network, addr string) (*SocketMonitor, error) {
71+
// Listen creates a new SocketMonitor by listening to the provided socket file or address.
72+
// An error is returned if unable to listen at the specified file path or port.
73+
//
74+
// Listen willl wait for a QEMU socket connection using a variety connection types:
75+
// Listen("unix", "/var/lib/qemu/example.monitor")
76+
// Listen("tcp", "0.0.0.0:4444")
77+
func Listen(network, addr string) (*SocketMonitor, error) {
7478
listener, listenerErr := net.Listen(network, addr)
7579
if listenerErr != nil {
7680
return nil, listenerErr
7781
}
7882
c, err := listener.Accept()
83+
defer listener.Close()
7984
if err != nil {
8085
return nil, err
8186
}

0 commit comments

Comments
 (0)