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
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
src/pkg/net/fd.go
src/pkg/net/fd.go
+10
-0
src/pkg/net/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 {
addr
,
err1
:=
sockaddrToString
(
sa
);
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 {
// Close closes the connection.
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,
// ReadFrom reads the next packet from the network,
// returning the number of bytes read and the remote
...
...
@@ -318,6 +324,20 @@ type connBase struct {
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
{
if
c
==
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