]> Cypherpunks repositories - gostls13.git/commit
net, internal/syscall/unix: add SocketConn, SocketPacketConn
authorMikio Hara <mikioh.mikioh@gmail.com>
Thu, 23 Apr 2015 14:57:00 +0000 (23:57 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Wed, 13 May 2015 01:04:23 +0000 (01:04 +0000)
commit6f7961da28232c609f7c51b3bed7f15db7dd33e1
treea8a32603037c1e63e45c9361fd705076c1ee70ad
parent08ba7dbdfdf0a2824ee122a6214e0263431a6ff0
net, internal/syscall/unix: add SocketConn, SocketPacketConn

FileConn and FilePacketConn APIs accept user-configured socket
descriptors to make them work together with runtime-integrated network
poller, but there's a limitation. The APIs reject protocol sockets that
are not supported by standard library. It's very hard for the net,
syscall packages to look after all platform, feature-specific sockets.

This change allows various platform, feature-specific socket descriptors
to use runtime-integrated network poller by using SocketConn,
SocketPacketConn APIs that bridge between the net, syscall packages and
platforms.

New exposed APIs:
pkg net, func SocketConn(*os.File, SocketAddr) (Conn, error)
pkg net, func SocketPacketConn(*os.File, SocketAddr) (PacketConn, error)
pkg net, type SocketAddr interface { Addr, Raw }
pkg net, type SocketAddr interface, Addr([]uint8) Addr
pkg net, type SocketAddr interface, Raw(Addr) []uint8

Fixes #10565.

Change-Id: Iec57499b3d84bb5cb0bcf3f664330c535eec11e3
Reviewed-on: https://go-review.googlesource.com/9275
Reviewed-by: Ian Lance Taylor <iant@golang.org>
14 files changed:
src/go/build/deps_test.go
src/internal/syscall/unix/socket.go [new file with mode: 0644]
src/internal/syscall/unix/socket_linux_386.go [new file with mode: 0644]
src/internal/syscall/unix/socket_linux_386.s [new file with mode: 0644]
src/internal/syscall/unix/socket_stub.go [new file with mode: 0644]
src/internal/syscall/unix/socket_unix.go [new file with mode: 0644]
src/net/fd_unix.go
src/net/file.go
src/net/file_bsd_test.go [new file with mode: 0644]
src/net/file_linux_test.go [new file with mode: 0644]
src/net/file_plan9.go
src/net/file_stub.go
src/net/file_unix.go
src/net/file_windows.go