Beispiel #1
0
// Connects to a specific server, and binds to a specified local IP
func (c *Client) ConnectToBind(addr *netutil.PortAddr, local *net.TCPAddr) {
	c.Disconnect()

	conn, err := dialTCP(addr.ToTCPAddr(), local)
	if err != nil {
		log.Fatal(err)
	}
	c.conn = conn

	go c.readLoop()
	go c.writeLoop()
}
Beispiel #2
0
// Connects to a specific server, and binds to a specified local IP
func (c *Client) ConnectToBind(addr *netutil.PortAddr, local *net.TCPAddr) {
	c.Disconnect()

	conn, err := dialTCP(addr.ToTCPAddr(), local)
	if err != nil {
		c.Fatalf("Connect failed: %v", err)
		return
	}
	c.conn = conn
	c.writeChan = make(chan IMsg, 5)

	go c.readLoop()
	go c.writeLoop()
}