File: already_connected.go

package info (click to toggle)
golang-github-digitalocean-go-libvirt 0.0~git20250902.14aca49-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,188 kB
  • sloc: yacc: 188; sh: 76; xml: 50; makefile: 3
file content (26 lines) | stat: -rw-r--r-- 867 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package dialers

import (
	"net"
)

// AlreadyConnected implements a dialer interface for a connection that was
// established prior to initializing the socket object.  This exists solely
// for backwards compatability with the previous implementation of Libvirt
// that took an already established connection.
type AlreadyConnected struct {
	c net.Conn
}

// NewAlreadyConnected is a noop dialer to simply use a connection previously
// established.  This means any re-dial attempts simply won't work.
func NewAlreadyConnected(c net.Conn) AlreadyConnected {
	return AlreadyConnected{c}
}

// Dial just returns the connection previously established.
// If at some point it is disconnected by the client, this obviously does *not*
// re-dial and will simply return the already closed connection.
func (a AlreadyConnected) Dial() (net.Conn, error) {
	return a.c, nil
}