Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
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
nexedi
caddy
Commits
4ff46ad4
Commit
4ff46ad4
authored
Jul 18, 2016
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Server into TCPServer and UDPServer
parent
59c6513b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
caddy.go
caddy.go
+21
-16
No files found.
caddy.go
View file @
4ff46ad4
...
...
@@ -235,20 +235,9 @@ func listenerAddrEqual(ln net.Listener, addr string) bool {
return
false
}
// Server is a type that can listen and serve.
//
// These methods must be implemented in pairs. If the server uses
// TCP, it should implement Listen() and Serve(). If it uses UDP
// or some other protocol, it should implement ListenPacket() and
// ServePacket(). If it uses both, all four methods should be
// implemented. Any unimplemented methods should be made as no-ops
// that simply return nil values.
//
// A Server must associate with exactly or one listeners and
// zero or one packetconns.
type
Server
interface
{
// TCP methods
// TCPServer is a type that can listen and serve connections.
// A TCPServer must associate with exactly or one net.Listeners.
type
TCPServer
interface
{
// Listen starts listening by creating a new listener
// and returning it. It does not start accepting
// connections. For UDP-only servers, this method
...
...
@@ -262,9 +251,11 @@ type Server interface {
// words, until the server is stopped. For UDP-only
// servers, this method can be a no-op that returns nil.
Serve
(
net
.
Listener
)
error
}
// UDP methods
// UDPServer is a type that can listen and serve packets.
// A UDPServer must associate with exactly or one net.PacketConns.
type
UDPServer
interface
{
// ListenPacket starts listening by creating a new packetconn
// and returning it. It does not start accepting connections.
// TCP-only servers may leave this method blank and return
...
...
@@ -280,6 +271,20 @@ type Server interface {
ServePacket
(
net
.
PacketConn
)
error
}
// Server is a type that can listen and serve. It supports both
// TCP and UDP, although the UDPServer interface can be used
// for more than just UDP.
//
// If the server uses TCP, it should implement TCPServer completely.
// If it uses UDP or some other protocol, it should implement
// UDPServer completely. If it uses both, both interfaces should be
// fully implemented. Any unimplemented methods should be made as
// no-ops that simply return nil values.
type
Server
interface
{
TCPServer
UDPServer
}
// Stopper is a type that can stop serving. The stop
// does not necessarily have to be graceful.
type
Stopper
interface
{
...
...
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