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

Function echo

experiments/gvisor-echo/echo.go:62–83  ·  view source on GitHub ↗
(wq *waiter.Queue, ep tcpip.Endpoint)

Source from the content-addressed store, hash-verified

60}
61
62func echo(wq *waiter.Queue, ep tcpip.Endpoint) {
63 defer ep.Close()
64
65 // Create wait queue entry that notifies a channel.
66 waitEntry, notifyCh := waiter.NewChannelEntry(waiter.ReadableEvents)
67 wq.EventRegister(&waitEntry)
68 defer wq.EventUnregister(&waitEntry)
69
70 for {
71 var buf bytes.Buffer
72 if _, err := ep.Read(&buf, tcpip.ReadOptions{}); err != nil {
73 if _, ok := err.(*tcpip.ErrWouldBlock); ok {
74 <-notifyCh
75 continue
76 }
77
78 return
79 }
80
81 log.Printf("received %q", buf.String())
82 }
83}
84
85func Main() error {
86 var args struct {

Callers 1

MainFunction · 0.85

Calls 3

CloseMethod · 0.45
ReadMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected