去写插座

编程入门 行业动态 更新时间:2024-10-28 13:26:58
本文介绍了去写插座 - 无效的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试着写在Go TCP套接字,但只有收到无效参数与此code:

_,ERR:= conn.Write([]字节(测试))如果犯错!= {为零    fmt.Println(err.Error())}

解决方案

下面是你想要做什么一个简单的示例(也许?),要知道,你应该做一个TCP服务器监听的端口 8999 第一次运行前,

NC -l 8999 #OR也许NC -l -p 8999

code:

主包进口(    净)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 8999

code:

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.

更多推荐

去写插座

本文发布于:2023-11-26 04:49:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1632692.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:插座

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!