Skip to content

Commit 2fb8fcd

Browse files
committed
add comment
1 parent 52a89c3 commit 2fb8fcd

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

netpoll.md

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,28 +109,6 @@ func socket(ctx context.Context, net string, family, sotype, proto int, ipv6only
109109
return nil, err
110110
}
111111

112-
// This function makes a network file descriptor for the
113-
// following applications:
114-
//
115-
// - An endpoint holder that opens a passive stream
116-
// connection, known as a stream listener
117-
//
118-
// - An endpoint holder that opens a destination-unspecific
119-
// datagram connection, known as a datagram listener
120-
//
121-
// - An endpoint holder that opens an active stream or a
122-
// destination-specific datagram connection, known as a
123-
// dialer
124-
//
125-
// - An endpoint holder that opens the other connection, such
126-
// as talking to the protocol stack inside the kernel
127-
//
128-
// For stream and datagram listeners, they will only require
129-
// named sockets, so we can assume that it's just a request
130-
// from stream or datagram listeners when laddr is not nil but
131-
// raddr is nil. Otherwise we assume it's just for dialers or
132-
// the other connection holders.
133-
134112
if laddr != nil && raddr == nil {
135113
switch sotype {
136114
case syscall.SOCK_STREAM, syscall.SOCK_SEQPACKET:
@@ -177,4 +155,6 @@ func (fd *netFD) listenStream(laddr sockaddr, backlog int) error {
177155
fd.setAddr(fd.addrFunc()(lsa), nil)
178156
return nil
179157
}
180-
```
158+
```
159+
160+
Go 的 listenTCP 一个函数就把 c 网络编程中 `socket()``bind()``listen()` 三步都完成了。大大减小了用户的心智负担。

0 commit comments

Comments
 (0)