forked from smallnest/rpcx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
98 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// +build rudp | ||
|
||
package client | ||
|
||
import ( | ||
"net" | ||
) | ||
|
||
func init() { | ||
makeConnMap["rudp"] = newDirectRUDPConn | ||
} | ||
|
||
func newDirectRUDPConn(c *Client, network, address string) (net.Conn, error) { | ||
addr, err := net.ResolveUDPAddr("udp", address) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
laddr := net.UDPAddr{IP: net.IPv4zero, Port: 0} | ||
return net.DialUDP("udp", &laddr, addr) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// +build utp | ||
|
||
package client | ||
|
||
import ( | ||
"net" | ||
|
||
"github.com/anacrolix/utp" | ||
) | ||
|
||
func init() { | ||
makeConnMap["utp"] = newDirectUTPConn | ||
} | ||
|
||
func newDirectUTPConn(c *Client, network, address string) (net.Conn, error) { | ||
return utp.Dial(address) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// +build rudp | ||
|
||
package server | ||
|
||
import ( | ||
"net" | ||
|
||
"github.com/u35s/rudp" | ||
) | ||
|
||
func init() { | ||
makeListeners["rudp"] = rudpMakeListener | ||
} | ||
|
||
func rudpMakeListener(s *Server, address string) (ln net.Listener, err error) { | ||
addr, err := net.ResolveUDPAddr("udp", address) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
l, err := net.ListenUDP("udp", addr) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return rudp.NewListener(l), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// +build utp | ||
|
||
package server | ||
|
||
import ( | ||
"net" | ||
|
||
"github.com/anacrolix/utp" | ||
) | ||
|
||
func init() { | ||
makeListeners["utp"] = utpMakeListener | ||
} | ||
|
||
func utpMakeListener(s *Server, address string) (ln net.Listener, err error) { | ||
return utp.Listen(address) | ||
} |