Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
77cb8956
Commit
77cb8956
authored
Jan 24, 2012
by
Mikio Hara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: consistent OpError message
R=golang-dev, rsc CC=golang-dev
https://golang.org/cl/5562047
parent
c1b4be6a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
29 deletions
+29
-29
src/pkg/net/iprawsock_posix.go
src/pkg/net/iprawsock_posix.go
+3
-3
src/pkg/net/tcpsock_plan9.go
src/pkg/net/tcpsock_plan9.go
+2
-2
src/pkg/net/tcpsock_posix.go
src/pkg/net/tcpsock_posix.go
+2
-2
src/pkg/net/udpsock_plan9.go
src/pkg/net/udpsock_plan9.go
+3
-3
src/pkg/net/udpsock_posix.go
src/pkg/net/udpsock_posix.go
+16
-16
src/pkg/net/unixsock_posix.go
src/pkg/net/unixsock_posix.go
+3
-3
No files found.
src/pkg/net/iprawsock_posix.go
View file @
77cb8956
...
...
@@ -191,7 +191,7 @@ func (c *IPConn) WriteToIP(b []byte, addr *IPAddr) (int, error) {
}
sa
,
err
:=
addr
.
sockaddr
(
c
.
fd
.
family
)
if
err
!=
nil
{
return
0
,
&
OpError
{
"write
toip"
,
"ip"
,
addr
,
err
}
return
0
,
&
OpError
{
"write
"
,
c
.
fd
.
net
,
addr
,
err
}
}
return
c
.
fd
.
WriteTo
(
b
,
sa
)
}
...
...
@@ -203,7 +203,7 @@ func (c *IPConn) WriteTo(b []byte, addr Addr) (int, error) {
}
a
,
ok
:=
addr
.
(
*
IPAddr
)
if
!
ok
{
return
0
,
&
OpError
{
"write
to"
,
"ip"
,
addr
,
os
.
EINVAL
}
return
0
,
&
OpError
{
"write
"
,
c
.
fd
.
net
,
addr
,
os
.
EINVAL
}
}
return
c
.
WriteToIP
(
b
,
a
)
}
...
...
@@ -221,7 +221,7 @@ func DialIP(netProto string, laddr, raddr *IPAddr) (*IPConn, error) {
return
nil
,
UnknownNetworkError
(
net
)
}
if
raddr
==
nil
{
return
nil
,
&
OpError
{
"dial
ip
"
,
netProto
,
nil
,
errMissingAddress
}
return
nil
,
&
OpError
{
"dial"
,
netProto
,
nil
,
errMissingAddress
}
}
fd
,
err
:=
internetSocket
(
net
,
laddr
.
toAddr
(),
raddr
.
toAddr
(),
syscall
.
SOCK_RAW
,
proto
,
"dial"
,
sockaddrToIP
)
if
err
!=
nil
{
...
...
src/pkg/net/tcpsock_plan9.go
View file @
77cb8956
...
...
@@ -60,7 +60,7 @@ func DialTCP(net string, laddr, raddr *TCPAddr) (c *TCPConn, err error) {
return
nil
,
UnknownNetworkError
(
net
)
}
if
raddr
==
nil
{
return
nil
,
&
OpError
{
"dial"
,
"tcp"
,
nil
,
errMissingAddress
}
return
nil
,
&
OpError
{
"dial"
,
net
,
nil
,
errMissingAddress
}
}
c1
,
err
:=
dialPlan9
(
net
,
laddr
,
raddr
)
if
err
!=
nil
{
...
...
@@ -87,7 +87,7 @@ func ListenTCP(net string, laddr *TCPAddr) (l *TCPListener, err error) {
return
nil
,
UnknownNetworkError
(
net
)
}
if
laddr
==
nil
{
return
nil
,
&
OpError
{
"listen"
,
"tcp"
,
nil
,
errMissingAddress
}
return
nil
,
&
OpError
{
"listen"
,
net
,
nil
,
errMissingAddress
}
}
l1
,
err
:=
listenPlan9
(
net
,
laddr
)
if
err
!=
nil
{
...
...
src/pkg/net/tcpsock_posix.go
View file @
77cb8956
...
...
@@ -225,7 +225,7 @@ func (c *TCPConn) File() (f *os.File, err error) { return c.fd.dup() }
// as the local address for the connection.
func
DialTCP
(
net
string
,
laddr
,
raddr
*
TCPAddr
)
(
c
*
TCPConn
,
err
error
)
{
if
raddr
==
nil
{
return
nil
,
&
OpError
{
"dial"
,
"tcp"
,
nil
,
errMissingAddress
}
return
nil
,
&
OpError
{
"dial"
,
net
,
nil
,
errMissingAddress
}
}
fd
,
e
:=
internetSocket
(
net
,
laddr
.
toAddr
(),
raddr
.
toAddr
(),
syscall
.
SOCK_STREAM
,
0
,
"dial"
,
sockaddrToTCP
)
if
e
!=
nil
{
...
...
@@ -253,7 +253,7 @@ func ListenTCP(net string, laddr *TCPAddr) (l *TCPListener, err error) {
err
=
syscall
.
Listen
(
fd
.
sysfd
,
listenerBacklog
)
if
err
!=
nil
{
closesocket
(
fd
.
sysfd
)
return
nil
,
&
OpError
{
"listen"
,
"tcp"
,
laddr
,
err
}
return
nil
,
&
OpError
{
"listen"
,
net
,
laddr
,
err
}
}
l
=
new
(
TCPListener
)
l
.
fd
=
fd
...
...
src/pkg/net/udpsock_plan9.go
View file @
77cb8956
...
...
@@ -110,7 +110,7 @@ func (c *UDPConn) WriteTo(b []byte, addr Addr) (n int, err error) {
}
a
,
ok
:=
addr
.
(
*
UDPAddr
)
if
!
ok
{
return
0
,
&
OpError
{
"write
to"
,
"udp"
,
addr
,
os
.
EINVAL
}
return
0
,
&
OpError
{
"write
"
,
c
.
dir
,
addr
,
os
.
EINVAL
}
}
return
c
.
WriteToUDP
(
b
,
a
)
}
...
...
@@ -125,7 +125,7 @@ func DialUDP(net string, laddr, raddr *UDPAddr) (c *UDPConn, err error) {
return
nil
,
UnknownNetworkError
(
net
)
}
if
raddr
==
nil
{
return
nil
,
&
OpError
{
"dial"
,
"udp"
,
nil
,
errMissingAddress
}
return
nil
,
&
OpError
{
"dial"
,
net
,
nil
,
errMissingAddress
}
}
c1
,
err
:=
dialPlan9
(
net
,
laddr
,
raddr
)
if
err
!=
nil
{
...
...
@@ -173,7 +173,7 @@ func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err error) {
return
nil
,
UnknownNetworkError
(
net
)
}
if
laddr
==
nil
{
return
nil
,
&
OpError
{
"listen"
,
"udp"
,
nil
,
errMissingAddress
}
return
nil
,
&
OpError
{
"listen"
,
net
,
nil
,
errMissingAddress
}
}
l
,
err
:=
listenPlan9
(
net
,
laddr
)
if
err
!=
nil
{
...
...
src/pkg/net/udpsock_posix.go
View file @
77cb8956
...
...
@@ -178,25 +178,25 @@ func (c *UDPConn) ReadFrom(b []byte) (n int, addr Addr, err error) {
// an error with Timeout() == true after a fixed time limit;
// see SetDeadline and SetWriteDeadline.
// On packet-oriented connections, write timeouts are rare.
func
(
c
*
UDPConn
)
WriteToUDP
(
b
[]
byte
,
addr
*
UDPAddr
)
(
n
int
,
err
error
)
{
func
(
c
*
UDPConn
)
WriteToUDP
(
b
[]
byte
,
addr
*
UDPAddr
)
(
int
,
error
)
{
if
!
c
.
ok
()
{
return
0
,
os
.
EINVAL
}
sa
,
err
1
:=
addr
.
sockaddr
(
c
.
fd
.
family
)
if
err
1
!=
nil
{
return
0
,
&
OpError
{
Op
:
"write"
,
Net
:
"udp"
,
Addr
:
addr
,
Err
:
err1
}
sa
,
err
:=
addr
.
sockaddr
(
c
.
fd
.
family
)
if
err
!=
nil
{
return
0
,
&
OpError
{
"write"
,
c
.
fd
.
net
,
addr
,
err
}
}
return
c
.
fd
.
WriteTo
(
b
,
sa
)
}
// WriteTo implements the net.PacketConn WriteTo method.
func
(
c
*
UDPConn
)
WriteTo
(
b
[]
byte
,
addr
Addr
)
(
n
int
,
err
error
)
{
func
(
c
*
UDPConn
)
WriteTo
(
b
[]
byte
,
addr
Addr
)
(
int
,
error
)
{
if
!
c
.
ok
()
{
return
0
,
os
.
EINVAL
}
a
,
ok
:=
addr
.
(
*
UDPAddr
)
if
!
ok
{
return
0
,
&
OpError
{
"write
to"
,
"udp"
,
addr
,
os
.
EINVAL
}
return
0
,
&
OpError
{
"write
"
,
c
.
fd
.
net
,
addr
,
os
.
EINVAL
}
}
return
c
.
WriteToUDP
(
b
,
a
)
}
...
...
@@ -211,7 +211,7 @@ func DialUDP(net string, laddr, raddr *UDPAddr) (c *UDPConn, err error) {
return
nil
,
UnknownNetworkError
(
net
)
}
if
raddr
==
nil
{
return
nil
,
&
OpError
{
"dial"
,
"udp"
,
nil
,
errMissingAddress
}
return
nil
,
&
OpError
{
"dial"
,
net
,
nil
,
errMissingAddress
}
}
fd
,
e
:=
internetSocket
(
net
,
laddr
.
toAddr
(),
raddr
.
toAddr
(),
syscall
.
SOCK_DGRAM
,
0
,
"dial"
,
sockaddrToUDP
)
if
e
!=
nil
{
...
...
@@ -224,18 +224,18 @@ func DialUDP(net string, laddr, raddr *UDPAddr) (c *UDPConn, err error) {
// local address laddr. The returned connection c's ReadFrom
// and WriteTo methods can be used to receive and send UDP
// packets with per-packet addressing.
func
ListenUDP
(
net
string
,
laddr
*
UDPAddr
)
(
c
*
UDPConn
,
err
error
)
{
func
ListenUDP
(
net
string
,
laddr
*
UDPAddr
)
(
*
UDPConn
,
error
)
{
switch
net
{
case
"udp"
,
"udp4"
,
"udp6"
:
default
:
return
nil
,
UnknownNetworkError
(
net
)
}
if
laddr
==
nil
{
return
nil
,
&
OpError
{
"listen"
,
"udp"
,
nil
,
errMissingAddress
}
return
nil
,
&
OpError
{
"listen"
,
net
,
nil
,
errMissingAddress
}
}
fd
,
e
:=
internetSocket
(
net
,
laddr
.
toAddr
(),
nil
,
syscall
.
SOCK_DGRAM
,
0
,
"listen"
,
sockaddrToUDP
)
if
e
!=
nil
{
return
nil
,
e
fd
,
e
rr
:=
internetSocket
(
net
,
laddr
.
toAddr
(),
nil
,
syscall
.
SOCK_DGRAM
,
0
,
"listen"
,
sockaddrToUDP
)
if
e
rr
!=
nil
{
return
nil
,
e
rr
}
return
newUDPConn
(
fd
),
nil
}
...
...
@@ -275,7 +275,7 @@ func (c *UDPConn) LeaveGroup(ifi *Interface, addr IP) error {
func
joinIPv4GroupUDP
(
c
*
UDPConn
,
ifi
*
Interface
,
ip
IP
)
error
{
err
:=
joinIPv4Group
(
c
.
fd
,
ifi
,
ip
)
if
err
!=
nil
{
return
&
OpError
{
"joinipv4group"
,
"udp"
,
&
IPAddr
{
ip
},
err
}
return
&
OpError
{
"joinipv4group"
,
c
.
fd
.
net
,
&
IPAddr
{
ip
},
err
}
}
return
nil
}
...
...
@@ -283,7 +283,7 @@ func joinIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) error {
func
leaveIPv4GroupUDP
(
c
*
UDPConn
,
ifi
*
Interface
,
ip
IP
)
error
{
err
:=
leaveIPv4Group
(
c
.
fd
,
ifi
,
ip
)
if
err
!=
nil
{
return
&
OpError
{
"leaveipv4group"
,
"udp"
,
&
IPAddr
{
ip
},
err
}
return
&
OpError
{
"leaveipv4group"
,
c
.
fd
.
net
,
&
IPAddr
{
ip
},
err
}
}
return
nil
}
...
...
@@ -291,7 +291,7 @@ func leaveIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) error {
func
joinIPv6GroupUDP
(
c
*
UDPConn
,
ifi
*
Interface
,
ip
IP
)
error
{
err
:=
joinIPv6Group
(
c
.
fd
,
ifi
,
ip
)
if
err
!=
nil
{
return
&
OpError
{
"joinipv6group"
,
"udp"
,
&
IPAddr
{
ip
},
err
}
return
&
OpError
{
"joinipv6group"
,
c
.
fd
.
net
,
&
IPAddr
{
ip
},
err
}
}
return
nil
}
...
...
@@ -299,7 +299,7 @@ func joinIPv6GroupUDP(c *UDPConn, ifi *Interface, ip IP) error {
func
leaveIPv6GroupUDP
(
c
*
UDPConn
,
ifi
*
Interface
,
ip
IP
)
error
{
err
:=
leaveIPv6Group
(
c
.
fd
,
ifi
,
ip
)
if
err
!=
nil
{
return
&
OpError
{
"leaveipv6group"
,
"udp"
,
&
IPAddr
{
ip
},
err
}
return
&
OpError
{
"leaveipv6group"
,
c
.
fd
.
net
,
&
IPAddr
{
ip
},
err
}
}
return
nil
}
src/pkg/net/unixsock_posix.go
View file @
77cb8956
...
...
@@ -259,7 +259,7 @@ func (c *UnixConn) WriteTo(b []byte, addr Addr) (n int, err error) {
}
a
,
ok
:=
addr
.
(
*
UnixAddr
)
if
!
ok
{
return
0
,
&
OpError
{
"write
to"
,
"unix"
,
addr
,
os
.
EINVAL
}
return
0
,
&
OpError
{
"write
"
,
c
.
fd
.
net
,
addr
,
os
.
EINVAL
}
}
return
c
.
WriteToUnix
(
b
,
a
)
}
...
...
@@ -330,7 +330,7 @@ func ListenUnix(net string, laddr *UnixAddr) (*UnixListener, error) {
err
=
syscall
.
Listen
(
fd
.
sysfd
,
listenerBacklog
)
if
err
!=
nil
{
closesocket
(
fd
.
sysfd
)
return
nil
,
&
OpError
{
Op
:
"listen"
,
Net
:
"unix"
,
Addr
:
laddr
,
Err
:
err
}
return
nil
,
&
OpError
{
Op
:
"listen"
,
Net
:
net
,
Addr
:
laddr
,
Err
:
err
}
}
return
&
UnixListener
{
fd
,
laddr
.
Name
},
nil
}
...
...
@@ -412,7 +412,7 @@ func ListenUnixgram(net string, laddr *UnixAddr) (c *UDPConn, err error) {
return
nil
,
UnknownNetworkError
(
net
)
}
if
laddr
==
nil
{
return
nil
,
&
OpError
{
"listen"
,
"unixgram"
,
nil
,
errMissingAddress
}
return
nil
,
&
OpError
{
"listen"
,
net
,
nil
,
errMissingAddress
}
}
fd
,
e
:=
unixSocket
(
net
,
laddr
,
nil
,
"listen"
)
if
e
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment