1 Star 0 Fork 0

wuzpdev/goworld

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
netutil.go 741 Bytes
Copy Edit Raw Blame History
seis authored 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)))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuzpdev/goworld.git
git@gitee.com:wuzpdev/goworld.git
wuzpdev
goworld
goworld
v0.1.2

Search

0d507c66 1850385 C8b1a773 1850385