Help us shape the future of Go! Take the 2026 Go Developer Survey

pairconnections

package module
v0.0.0-...-152f445 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2017 License: MIT Imports: 2 Imported by: 0

README

Simple method for create two local tcp connections, connected each to other. It is good for use in auto-tests.

func TestCreateTwoTCPConnections(t *testing.T) {
	c1, c2 := CreateTCPPairConnections()
	defer c1.Close()
	defer c2.Close()

	go func() {
		c1.Write([]byte("asd"))
		c1.Write([]byte("aaa"))
		c1.Write([]byte("555"))
		c1.Close()
	}()
	buf, err := ioutil.ReadAll(c2)
	if err != nil {
		panic(err)
	}
	if string(buf) != "asdaaa555" {
		t.Errorf("%s", buf)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTCPPairConnections

func CreateTCPPairConnections() (c1, c2 *net.TCPConn)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL