Is there a good open source TCP/UDP server?

polaris · · 788 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;m new to go and I am looking for a good TCP/UDP server. I see examples of how to write one but I don&#39;t want to reinvent the wheel. </p> <p>Is there a well used/maintained TCP/UDP server that people recommend?</p> <hr/>**评论:**<br/><br/>DavidDavidsonsGhost: <pre><p>Eh, not sure what you are looking for since the bit that isn&#39;t implementation specific is just like few lines of code. Here&#39;s how you make a listener. <a href="http://golang.org/pkg/net/#example_Listener" rel="nofollow">http://golang.org/pkg/net/#example_Listener</a></p> <p>Just replace the go function with your own handler function.</p></pre>golangnewb: <pre><p>Thank you.</p> <p>I have seen examples of this a bunch but was wondering if there was other things I was missing. If I was missing something, I was hoping for an open source one that tied it all together.</p> <p>If there isn&#39;t, I will probably play around with this and use channels to communicate with the main go routine to keep things synchronized.</p> <p>Thanks again for the help.</p></pre>thomasfr: <pre><p>The standard library net package is the open source one that ties it all together. </p></pre>pzduniak: <pre><p>Just check the source of net/http for an example.</p></pre>nhooyr: <pre><p>What are you looking for? TCP is a general protocol. You listen on a port, accept connections, and data moves through this connection. It can be anything, JSON, HTTP, TLS, files etc. You can take a look at <a href="https://github.com/aubble/goChat" rel="nofollow">https://github.com/aubble/goChat</a> which is a TCP chat server for an example. Its not that well documented but the code is well written. Take a look at net/http for a HTTP server etc. In the end TCP is just a general protocol. You should google some networking books/concepts to get a better understanding. Trust me, it will help a lot.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

788 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传