github.com/la5nta/wl2k-go@v0.11.8/transport/ax25/agwpe/tnc_port.go (about) 1 package agwpe 2 3 // TNCPort representw a TNC connection with a single registered port. 4 type TNCPort struct { 5 TNC 6 Port 7 } 8 9 // Close closes both the port and TNC. 10 func (tp TNCPort) Close() error { tp.Port.Close(); return tp.TNC.Close() } 11 12 // OpenPortTCP opens a connection to the TNC and registers a single port. 13 // 14 // The returned TNCPort is a reference to the combined Port and TNC. 15 func OpenPortTCP(addr string, port int, callsign string) (*TNCPort, error) { 16 t, err := OpenTCP(addr) 17 if err != nil { 18 return nil, err 19 } 20 p, err := t.RegisterPort(port, callsign) 21 if err != nil { 22 t.Close() 23 return nil, err 24 } 25 return &TNCPort{*t, *p}, nil 26 }