Skip to content

Commit d82d6e2

Browse files
committed
chore: remove UDP support and unused future roadmap
UDP was never implemented (listener returned ErrUnsupported, dialer was commented out). Remove all dead UDP code paths and return an explicit error for UDP networks in CreateListener. Also remove the Future roadmap section from READMEs as there is no plan to support these.
1 parent b57c19c commit d82d6e2

6 files changed

Lines changed: 17 additions & 67 deletions

File tree

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ For more information, please refer to [Document](#document).
5353
- TCP, Unix Domain Socket
5454
- Linux, macOS (operating system)
5555

56-
* **Future**
57-
- [io_uring][io_uring]
58-
- Shared Memory IPC
59-
- TLS
60-
- UDP
61-
6256
* **Unsupported**
6357
- Windows (operating system)
6458

@@ -100,4 +94,3 @@ More benchmarks reference [kitex-benchmark][kitex-benchmark] and [hertz-benchmar
10094
[LinkBuffer]: nocopy_linkbuffer.go
10195
[gopool]: https://github.com/bytedance/gopkg/tree/develop/util/gopool
10296
[mcache]: https://github.com/bytedance/gopkg/tree/develop/lang/mcache
103-
[io_uring]: https://github.com/axboe/liburing

README_CN.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ goroutine,大幅增加调度开销。此外,[net.Conn][net.Conn] 没有提
4848
- 支持 TCP,Unix Domain Socket
4949
- 支持 Linux,macOS(操作系统)
5050

51-
* **即将开源**
52-
- [io_uring][io_uring]
53-
- Shared Memory IPC
54-
- 支持 TLS
55-
- 支持 UDP
56-
5751
* **不被支持**
5852
- Windows(操作系统)
5953

@@ -93,4 +87,3 @@ goroutine,大幅增加调度开销。此外,[net.Conn][net.Conn] 没有提
9387
[LinkBuffer]: nocopy_linkbuffer.go
9488
[gopool]: https://github.com/bytedance/gopkg/tree/develop/util/gopool
9589
[mcache]: https://github.com/bytedance/gopkg/tree/develop/lang/mcache
96-
[io_uring]: https://github.com/axboe/liburing

net_dialer.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ func (d *dialer) DialConnection(network, address string, timeout time.Duration)
7070
switch network {
7171
case "tcp", "tcp4", "tcp6":
7272
return d.dialTCP(ctx, network, address)
73-
// case "udp", "udp4", "udp6": // TODO: unsupported now
7473
case "unix", "unixgram", "unixpacket":
7574
raddr := &UnixAddr{
7675
UnixAddr: net.UnixAddr{Name: address, Net: network},

net_listener.go

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ import (
2626

2727
// CreateListener return a new Listener.
2828
func CreateListener(network, addr string) (l Listener, err error) {
29-
if network == "udp" {
30-
// TODO: udp listener.
31-
return udpListener(network, addr)
29+
if network == "udp" || network == "udp4" || network == "udp6" {
30+
return nil, Exception(ErrUnsupported, "UDP")
3231
}
3332
// tcp, tcp4, tcp6, unix
3433
ln, err := net.Listen(network, addr)
@@ -53,42 +52,17 @@ func ConvertListener(l net.Listener) (nl Listener, err error) {
5352
return ln, syscall.SetNonblock(ln.fd, true)
5453
}
5554

56-
// TODO: udpListener does not work now.
57-
func udpListener(network, addr string) (l Listener, err error) {
58-
ln := &listener{}
59-
ln.pconn, err = net.ListenPacket(network, addr)
60-
if err != nil {
61-
return nil, err
62-
}
63-
ln.addr = ln.pconn.LocalAddr()
64-
switch pconn := ln.pconn.(type) {
65-
case *net.UDPConn:
66-
ln.file, err = pconn.File()
67-
}
68-
if err != nil {
69-
return nil, err
70-
}
71-
ln.fd = int(ln.file.Fd())
72-
return ln, syscall.SetNonblock(ln.fd, true)
73-
}
74-
7555
var _ net.Listener = &listener{}
7656

7757
type listener struct {
78-
fd int
79-
addr net.Addr // listener's local addr
80-
ln net.Listener // tcp|unix listener
81-
pconn net.PacketConn // udp listener
82-
file *os.File
58+
fd int
59+
addr net.Addr // listener's local addr
60+
ln net.Listener // tcp|unix listener
61+
file *os.File
8362
}
8463

8564
// Accept implements Listener.
8665
func (ln *listener) Accept() (net.Conn, error) {
87-
// udp
88-
if ln.pconn != nil {
89-
return ln.UDPAccept()
90-
}
91-
// tcp
9266
fd, sa, err := syscall.Accept(ln.fd)
9367
if err != nil {
9468
/* https://man7.org/linux/man-pages/man2/accept.2.html
@@ -112,11 +86,6 @@ func (ln *listener) Accept() (net.Conn, error) {
11286
return nfd, nil
11387
}
11488

115-
// TODO: UDPAccept Not implemented.
116-
func (ln *listener) UDPAccept() (net.Conn, error) {
117-
return nil, Exception(ErrUnsupported, "UDP")
118-
}
119-
12089
// Close implements Listener.
12190
func (ln *listener) Close() error {
12291
if ln.fd != 0 {
@@ -128,9 +97,6 @@ func (ln *listener) Close() error {
12897
if ln.ln != nil {
12998
ln.ln.Close()
13099
}
131-
if ln.pconn != nil {
132-
ln.pconn.Close()
133-
}
134100
return nil
135101
}
136102

net_netfd.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ type netFD struct {
3333
pd *pollDesc
3434
// closed marks whether fd has expired
3535
closed uint32
36-
// Whether this is a streaming descriptor, as opposed to a
37-
// packet-based descriptor like a UDP socket. Immutable.
36+
// Whether this is a streaming descriptor. Immutable.
3837
isStream bool
3938
// Whether a zero byte read indicates EOF. This is false for a
4039
// message based socket connection.
4140
zeroReadIsEOF bool
4241
family int // AF_INET, AF_INET6, syscall.AF_UNIX
4342
sotype int // syscall.SOCK_STREAM, syscall.SOCK_DGRAM, syscall.SOCK_RAW
4443
isConnected bool // handshake completed or use of association with peer
45-
network string // tcp tcp4 tcp6, udp, udp4, udp6, ip, ip4, ip6, unix, unixgram, unixpacket
44+
network string // tcp, tcp4, tcp6, unix, unixgram, unixpacket
4645
localAddr net.Addr
4746
remoteAddr net.Addr
4847
// for detaching conn from poller

net_sock.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"syscall"
1818
)
1919

20-
// A sockaddr represents a TCP, UDP, IP or Unix network endpoint
20+
// A sockaddr represents a TCP, IP or Unix network endpoint
2121
// address that can be converted into a syscall.Sockaddr.
2222
type sockaddr interface {
2323
net.Addr
@@ -55,8 +55,8 @@ func internetSocket(ctx context.Context, net string, laddr, raddr sockaddr, soty
5555
// address family, both AF_INET and AF_INET6, and a wildcard address
5656
// like the following:
5757
//
58-
// - A listen for a wildcard communication domain, "tcp" or
59-
// "udp", with a wildcard address: If the platform supports
58+
// - A listen for a wildcard communication domain, "tcp",
59+
// with a wildcard address: If the platform supports
6060
// both IPv6 and IPv4-mapped IPv6 communication capabilities,
6161
// or does not support IPv4, we use a dual stack, AF_INET6 and
6262
// IPV6_V6ONLY=0, wildcard address listen. The dual stack
@@ -65,17 +65,17 @@ func internetSocket(ctx context.Context, net string, laddr, raddr sockaddr, soty
6565
// Otherwise we prefer an IPv4-only, AF_INET, wildcard address
6666
// listen.
6767
//
68-
// - A listen for a wildcard communication domain, "tcp" or
69-
// "udp", with an IPv4 wildcard address: same as above.
68+
// - A listen for a wildcard communication domain, "tcp",
69+
// with an IPv4 wildcard address: same as above.
7070
//
71-
// - A listen for a wildcard communication domain, "tcp" or
72-
// "udp", with an IPv6 wildcard address: same as above.
71+
// - A listen for a wildcard communication domain, "tcp",
72+
// with an IPv6 wildcard address: same as above.
7373
//
74-
// - A listen for an IPv4 communication domain, "tcp4" or "udp4",
74+
// - A listen for an IPv4 communication domain, "tcp4",
7575
// with an IPv4 wildcard address: We use an IPv4-only, AF_INET,
7676
// wildcard address listen.
7777
//
78-
// - A listen for an IPv6 communication domain, "tcp6" or "udp6",
78+
// - A listen for an IPv6 communication domain, "tcp6",
7979
// with an IPv6 wildcard address: We use an IPv6-only, AF_INET6
8080
// and IPV6_V6ONLY=1, wildcard address listen.
8181
//

0 commit comments

Comments
 (0)