MCPcopy
hub / github.com/monasticacademy/httptap / Main

Function Main

experiments/fin/fin-experiment.go:15–36  ·  view source on GitHub ↗

this is a TCP server that writes a fixed string and then closes the connection, in order to investigate the behavior of netcat with respect to FIN packets

()

Source from the content-addressed store, hash-verified

13// behavior of netcat with respect to FIN packets
14
15func Main() error {
16 var args struct {
17 Addr string `arg:"positional" default:":11223"`
18 }
19 arg.MustParse(&args)
20
21 log.Printf("listening on %v ...", args.Addr)
22 l, err := net.Listen("tcp", args.Addr)
23 if err != nil {
24 return fmt.Errorf("error listening on %v: %w", args.Addr, err)
25 }
26 for {
27 conn, err := l.Accept()
28 if err != nil {
29 return err
30 }
31
32 fmt.Fprintln(conn, "hello fin experiment")
33 conn.Close()
34 log.Printf("accepted and closed a connection from %v", conn.RemoteAddr())
35 }
36}
37
38func main() {
39 log.SetOutput(os.Stdout)

Callers 1

mainFunction · 0.70

Calls 3

AcceptMethod · 0.65
RemoteAddrMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected