aboutsummaryrefslogtreecommitdiff
path: root/transport/tcp.go
blob: 2ab946ad24b3da783e1212ec06b9744943853afb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package transport

import (
	"context"
	"net"
)

type TCP struct {
	Bind string
}

func (t *TCP) Run(ctx context.Context, resolver Resolver) error {
	ln, _ := net.Listen("tcp", t.Bind)

	for {
		conn, err := ln.Accept()
		if err != nil {
			return err
		}
		go resolver.Resolve(ctx, conn, conn)
	}
}