File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 44 This is returned by the [`Accept()`](https://pkg.go.dev/net#Listener.Accept) method.
55
66 ```go
7- # The return value value includes:
8- # 1. the client's connection (a `net.Conn` object)
9- # 2. an error (if any)
7+ // The return value value includes:
8+ // 1. the client's connection (a `net.Conn` object)
9+ // 2. an error (if any)
1010 conn, err := listener.Accept()
1111 ```
1212
1717 Use the [`Write()`](https://pkg.go.dev/net#Conn.Write) method on the client's connection:
1818
1919 ```go
20- # Send the response to the client
20+ // Send the response to the client
2121 conn.Write([]byte("+PONG\r\n"))
2222 ```
2323
Original file line number Diff line number Diff line change 11hints :
22 - title_markdown : " How do I access the client's TCP connection?"
33 body_markdown : |-
4- This is returned by the [`incoming()`](https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.into_incoming ) method.
4+ This is returned by the [`incoming()`](https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming ) method.
55
66 ```rust
7- # The return value is an iterator that provides a sequence of `TcpStream` objects.
7+ // The return value is an iterator that provides a sequence of `TcpStream` objects.
88 for stream in listener.incoming()
99 ```
1010
1515 Use the [`write_all()`](https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all) method on the client's connection:
1616
1717 ```rust
18- # Send the response to the client
18+ // Send the response to the client
1919 stream.write_all(b"+PONG\r\n").unwrap();
2020 ```
2121
You can’t perform that action at this time.
0 commit comments