本文介绍了去写插座 - 无效的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试着写在Go TCP套接字,但只有收到无效参数与此code:
_,ERR:= conn.Write([]字节(测试))如果犯错!= {为零 fmt.Println(err.Error())}解决方案
下面是你想要做什么一个简单的示例(也许?),要知道,你应该做一个TCP服务器监听的端口 8999 第一次运行前,
NC -l 8999 #OR也许NC -l -p 8999code:
主包进口( 净)FUNC的main(){ 康涅狄格州,_:= net.Dial(TCP,本地主机:8999) conn.Write([]字节(测试))}如果这不是你的问题,你应该提供更多的信息。
Im trying to write to a TCP socket in Go but only receive "invalid argument" with this code:
_, err := conn.Write([]byte("test")) if err != nil { fmt.Println(err.Error()) }解决方案
Here is a simple sample of what you want to do(maybe?), be aware that you should make a tcp server listen to the port 8999 first before run it
nc -l 8999 #or maybe nc -l -p 8999code:
package main import ( "net" ) func main() { conn, _ := net.Dial("tcp", "localhost:8999") conn.Write([]byte("test")) }If it's not your question, you should provide more information.
更多推荐
去写插座
发布评论