Permalink
Browse files

add Listen function

  • Loading branch information...
1 parent 99c8873 commit a50fdae10e39dfdca88fb31eeedb6f08abfbed6a @bradfitz committed Oct 19, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 listen/listen.go
View
@@ -10,6 +10,7 @@ import (
"strings"
)
+// NewFlag returns a flag that implements the flag.Value interface.
func NewFlag(flagName, defaultValue string, serverType string) *Addr {
addr := &Addr{
s: defaultValue,
@@ -18,6 +19,15 @@ func NewFlag(flagName, defaultValue string, serverType string) *Addr {
return addr
}
+// Listen is a replacement for net.Listen that also respects runsit
+// listeners: port, :port, ip:port, FD:<fd_num>, ADDR:<name> or <name>
+// named ports.
+// Listeners are always TCP.
+func Listen(addr string) (net.Listener, error) {
+ a := &Addr{s: addr}
+ return a.Listen()
+}
+
// Usage returns a descriptive usage message for a flag given the name
// of thing being addressed.
func Usage(name string) string {

0 comments on commit a50fdae

Please sign in to comment.