7 Star 26 Fork 2

Gitee 极速下载 / goworld

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/xiaonanln/goworld
克隆/下载
netutil.go 741 Bytes
一键复制 编辑 原始数据 按行查看 历史
seis 提交于 2017-10-23 15:28 . add heartbeat from client
package netutil
import (
"fmt"
"io"
"net"
"unsafe"
"github.com/pkg/errors"
)
// IsConnectionError check if the error is a connection error (close)
func IsConnectionError(_err interface{}) bool {
err, ok := _err.(error)
if !ok {
return false
}
err = errors.Cause(err)
if err == io.EOF {
return true
}
neterr, ok := err.(net.Error)
if !ok {
return false
}
if neterr.Timeout() {
return false
}
return true
}
// ConnectTCP connects to host:port in TCP
func ConnectTCP(host string, port int) (net.Conn, error) {
addr := fmt.Sprintf("%s:%d", host, port)
conn, err := net.Dial("tcp", addr)
return conn, err
}
func PutFloat32(b []byte, f float32) {
NETWORK_ENDIAN.PutUint32(b, *(*uint32)(unsafe.Pointer(&f)))
}
1
https://gitee.com/mirrors/goworld.git
git@gitee.com:mirrors/goworld.git
mirrors
goworld
goworld
v0.1.6

搜索帮助