Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
efc4088c
Commit
efc4088c
authored
Jun 19, 2009
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make IP address available
R=rsc DELTA=30 (30 added, 0 deleted, 0 changed) OCL=30536 CL=30536
parent
7f3eb273
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
fd.go
src/pkg/net/fd.go
+10
-0
net.go
src/pkg/net/net.go
+20
-0
No files found.
src/pkg/net/fd.go
View file @
efc4088c
...
@@ -436,3 +436,13 @@ func (fd *netFD) addr() string {
...
@@ -436,3 +436,13 @@ func (fd *netFD) addr() string {
addr
,
err1
:=
sockaddrToString
(
sa
);
addr
,
err1
:=
sockaddrToString
(
sa
);
return
addr
;
return
addr
;
}
}
func
(
fd
*
netFD
)
remoteAddr
()
string
{
sa
,
err
:=
syscall
.
Getpeername
(
fd
.
fd
);
if
err
!=
0
{
return
""
;
}
// TODO(rsc): woud like to say err not err1 but 6g complains
addr
,
err1
:=
sockaddrToString
(
sa
);
return
addr
;
}
src/pkg/net/net.go
View file @
efc4088c
...
@@ -33,6 +33,12 @@ type Conn interface {
...
@@ -33,6 +33,12 @@ type Conn interface {
// Close closes the connection.
// Close closes the connection.
Close
()
os
.
Error
;
Close
()
os
.
Error
;
// LocalAddr returns the local network address.
LocalAddr
()
string
;
// RemoteAddr returns the remote network address.
RemoteAddr
()
string
;
// For packet-based protocols such as UDP,
// For packet-based protocols such as UDP,
// ReadFrom reads the next packet from the network,
// ReadFrom reads the next packet from the network,
// returning the number of bytes read and the remote
// returning the number of bytes read and the remote
...
@@ -318,6 +324,20 @@ type connBase struct {
...
@@ -318,6 +324,20 @@ type connBase struct {
raddr
string
;
raddr
string
;
}
}
func
(
c
*
connBase
)
LocalAddr
()
string
{
if
c
==
nil
{
return
""
}
return
c
.
fd
.
addr
();
}
func
(
c
*
connBase
)
RemoteAddr
()
string
{
if
c
==
nil
{
return
""
}
return
c
.
fd
.
remoteAddr
();
}
func
(
c
*
connBase
)
File
()
*
os
.
File
{
func
(
c
*
connBase
)
File
()
*
os
.
File
{
if
c
==
nil
{
if
c
==
nil
{
return
nil
return
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