Commit 484cdc1d authored by AlexStocks's avatar AlexStocks

let udp client/server session run

parent 09fe6560
......@@ -11,6 +11,10 @@
## develop history ##
---
- 2018/03/08
> feature
* 1 add udp client and udp server
- 2017/05/02
> feature
* 1 set read/write deadline for every read/write action refers to fasthttp
......
......@@ -10,7 +10,6 @@
package getty
import (
// "errors"
"compress/flate"
"crypto/tls"
"fmt"
......@@ -581,6 +580,7 @@ func (u *gettyUDPConn) read(p []byte) (int, *net.UDPAddr, error) {
length, addr, err = u.conn.ReadFromUDP(p)
} else {
length, err = u.conn.Read(p)
addr = u.peerAddr
}
if err == nil {
atomic.AddUint32(&u.readCount, uint32(length))
......
......@@ -182,6 +182,10 @@ func (s *Server) listenUDP() error {
if err != nil {
return errors.Wrapf(err, "net.ListenUDP((udp, localAddr:%#v)", localAddr)
}
if err = setUDPSocketOptions(udpConn); err != nil {
return errors.Wrapf(err, "setUDPSocketOptions(udpConn:%#v)", udpConn)
}
s.udpConn = udpConn
return nil
......@@ -268,6 +272,7 @@ func (s *Server) runUDPEventloop(newSession NewSessionCallback) {
if err := newSession(ss); err != nil {
panic(err.Error())
}
ss.(*session).run()
}
type wsHandler struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment