MCPcopy Index your code
hub / github.com/coder/coder / tcpEchoServer

Function tcpEchoServer

enterprise/coderd/coderd_test.go:1227–1249  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1225}
1226
1227func tcpEchoServer(t *testing.T) string {
1228 tcpListener, err := net.Listen("tcp", "127.0.0.1:0")
1229 require.NoError(t, err)
1230 t.Cleanup(func() {
1231 _ = tcpListener.Close()
1232 })
1233 go func() {
1234 for {
1235 conn, err := tcpListener.Accept()
1236 if err != nil {
1237 return
1238 }
1239 t.Cleanup(func() {
1240 _ = conn.Close()
1241 })
1242 go func() {
1243 defer conn.Close()
1244 _, _ = io.Copy(conn, conn)
1245 }()
1246 }
1247 }()
1248 return tcpListener.Addr().String()
1249}
1250
1251// nolint:revive // t takes precedence.
1252func writeReadEcho(t *testing.T, ctx context.Context, conn net.Conn) {

Callers 1

Calls 7

ListenMethod · 0.65
CleanupMethod · 0.65
CloseMethod · 0.65
CopyMethod · 0.65
AcceptMethod · 0.45
StringMethod · 0.45
AddrMethod · 0.45

Tested by

no test coverage detected