Skip to content

Instantly share code, notes, and snippets.

@xintron
Created November 26, 2013 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xintron/7657317 to your computer and use it in GitHub Desktop.
Save xintron/7657317 to your computer and use it in GitHub Desktop.
func (conn *Conn) Connect(host string) (c net.Conn, err error) {
log.SetFlags(23)
log.Printf("Connecting to host: %s\n", host)
// Wrapp the connection with a secure connection
if conn.SSL {
c, err = tls.Dial("tcp", host, conn.SSLConfig)
} else {
c, err = net.Dial("tcp", host)
}
if err != nil {
log.Panicf("Could not connect to server: %s\n", err.Error())
}
conn.Host = host
conn.sock = c
conn.Connected = true
conn.postConnect()
return conn.sock, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment