tractor.dev/toolkit-go@v0.0.0-20241010005851-214d91207d07/duplex/mux/dial_net.go (about)

     1  package mux
     2  
     3  import (
     4  	"net"
     5  )
     6  
     7  func dialNet(proto, addr string) (Session, error) {
     8  	conn, err := net.Dial(proto, addr)
     9  	if err != nil {
    10  		return nil, err
    11  	}
    12  	return New(conn), nil
    13  }
    14  
    15  // DialTCP establishes a mux session via TCP connection.
    16  func DialTCP(addr string) (Session, error) {
    17  	return dialNet("tcp", addr)
    18  }
    19  
    20  // DialUnix establishes a mux session via Unix domain socket.
    21  func DialUnix(path string) (Session, error) {
    22  	return dialNet("unix", path)
    23  }