DialTimeout is used to create a connection that allows memberlist to perform two-way communication with a peer.
(addr string, timeout time.Duration)
| 597 | // DialTimeout is used to create a connection that allows memberlist to perform |
| 598 | // two-way communication with a peer. |
| 599 | func (t *TCPTransport) DialTimeout(addr string, timeout time.Duration) (net.Conn, error) { |
| 600 | t.outgoingStreams.Inc() |
| 601 | c, err := t.getConnection(addr, timeout) |
| 602 | |
| 603 | if err != nil { |
| 604 | t.outgoingStreamErrors.Inc() |
| 605 | return nil, err |
| 606 | } |
| 607 | |
| 608 | _, err = c.Write([]byte{byte(stream)}) |
| 609 | if err != nil { |
| 610 | t.outgoingStreamErrors.Inc() |
| 611 | _ = c.Close() |
| 612 | return nil, err |
| 613 | } |
| 614 | |
| 615 | return c, nil |
| 616 | } |
| 617 | |
| 618 | // StreamCh returns a channel that can be read to handle incoming stream |
| 619 | // connections from other peers. |