github.com/arieschain/arieschain@v0.0.0-20191023063405-37c074544356/p2p/netutil/toobig_windows.go (about)

     1  //+build windows
     2  
     3  package netutil
     4  
     5  import (
     6  	"net"
     7  	"os"
     8  	"syscall"
     9  )
    10  
    11  const _WSAEMSGSIZE = syscall.Errno(10040)
    12  
    13  // isPacketTooBig reports whether err indicates that a UDP packet didn't
    14  // fit the receive buffer. On Windows, WSARecvFrom returns
    15  // code WSAEMSGSIZE and no data if this happens.
    16  func isPacketTooBig(err error) bool {
    17  	if opErr, ok := err.(*net.OpError); ok {
    18  		if scErr, ok := opErr.Err.(*os.SyscallError); ok {
    19  			return scErr.Err == _WSAEMSGSIZE
    20  		}
    21  		return opErr.Err == _WSAEMSGSIZE
    22  	}
    23  	return false
    24  }