mirror of
https://github.com/xtaci/kcp-go.git
synced 2024-04-21 12:32:15 +00:00
rename var
This commit is contained in:
+5
-5
@@ -20,7 +20,7 @@ func (s *UDPSession) readLoop() {
|
||||
}
|
||||
|
||||
for {
|
||||
if count, err := s.bconn.ReadBatch(msgs, 0); err == nil {
|
||||
if count, err := s.xconn.ReadBatch(msgs, 0); err == nil {
|
||||
for i := 0; i < count; i++ {
|
||||
msg := &msgs[i]
|
||||
// make sure the packet is from the same source
|
||||
@@ -49,11 +49,11 @@ func (s *UDPSession) readLoop() {
|
||||
// monitor incoming data for all connections of server
|
||||
func (l *Listener) monitor() {
|
||||
addr, _ := net.ResolveUDPAddr("udp", l.conn.LocalAddr().String())
|
||||
var conn batchConn
|
||||
var xconn batchConn
|
||||
if addr.IP.To4() != nil {
|
||||
conn = ipv4.NewPacketConn(l.conn)
|
||||
xconn = ipv4.NewPacketConn(l.conn)
|
||||
} else {
|
||||
conn = ipv6.NewPacketConn(l.conn)
|
||||
xconn = ipv6.NewPacketConn(l.conn)
|
||||
}
|
||||
|
||||
msgs := make([]ipv4.Message, batchSize)
|
||||
@@ -62,7 +62,7 @@ func (l *Listener) monitor() {
|
||||
}
|
||||
|
||||
for {
|
||||
if count, err := conn.ReadBatch(msgs, 0); err == nil {
|
||||
if count, err := xconn.ReadBatch(msgs, 0); err == nil {
|
||||
for i := 0; i < count; i++ {
|
||||
msg := &msgs[i]
|
||||
if msg.N >= l.headerSize+IKCP_OVERHEAD {
|
||||
|
||||
@@ -98,7 +98,7 @@ type (
|
||||
|
||||
// packets waiting to be sent on wire
|
||||
txqueue []ipv4.Message
|
||||
bconn batchConn // for casting of batchConn
|
||||
xconn batchConn // for x/net
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
@@ -131,9 +131,9 @@ func newUDPSession(conv uint32, dataShards, parityShards int, l *Listener, conn
|
||||
// cast to writebatch conn
|
||||
addr, _ := net.ResolveUDPAddr("udp", conn.LocalAddr().String())
|
||||
if addr.IP.To4() != nil {
|
||||
sess.bconn = ipv4.NewPacketConn(conn)
|
||||
sess.xconn = ipv4.NewPacketConn(conn)
|
||||
} else {
|
||||
sess.bconn = ipv6.NewPacketConn(conn)
|
||||
sess.xconn = ipv6.NewPacketConn(conn)
|
||||
}
|
||||
|
||||
// FEC codec initialization
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ func (s *UDPSession) tx(txqueue []ipv4.Message) {
|
||||
nbytes := 0
|
||||
npkts := 0
|
||||
for len(txqueue) > 0 {
|
||||
if n, err := s.bconn.WriteBatch(txqueue, 0); err == nil {
|
||||
if n, err := s.xconn.WriteBatch(txqueue, 0); err == nil {
|
||||
for k := range txqueue[:n] {
|
||||
nbytes += len(txqueue[k].Buffers[0])
|
||||
xmitBuf.Put(txqueue[k].Buffers[0])
|
||||
|
||||
Reference in New Issue
Block a user