gislu / gosocket Goto Github PK
View Code? Open in Web Editor NEWA socket server built by native Go http package.
A socket server built by native Go http package.
看上去简单好用,请问在工作生产环境中在用了吗?
在 WIN7 64 下配合 GoLand IDE 进行调试,Server 端显示接收数据如下:
127.0.0.1:49185 tcp connect success
receive data string: {"ID":8","Session":15646195752952399002015073109532345","Meta":"golang","Content":"message"}
receive data string: {"ID":18","Session":15646195752952399002015073109532345","Meta":"golang","Content":"message"}
receive data string: {"ID":28","Session":15646195752952399002015073109532345","Meta":"golang","Content":"message"}
receive data string: {"ID":38","Session":15646195752952399002015073109532345","Meta":"golang","Content":"message"}
receive data string: {"ID":48","Session":15646195752952399002015073109532345","Meta":"golang","Content":"message"}
receive data string: {"ID":58","Session":15646195752952399002015073109532345","Meta":"golang","Content":"message"}
receive data string: {"ID":68","Session":15646195752952399002015073109532345","Meta":"golang","Content":"message"}
receive data string: {"ID":77","Session":15646195752952399002015073109532345","Meta":"golang","Content":"message"}
receive data string: {"ID":87","Session":15646195752952399002015073109532345","Meta":"golang","Content":"message"}
receive data string: {"ID":97","Session":15646195752952399002015073109532345","Meta":"golang","Content":"message"}
receive data string: {"ID":99","Session":15646195752952399002015073109532345","Meta":"golang","Content":"message"}
127.0.0.1:49185 connection error: EOF
如上所示,求教:
1.为何ID会断续存储?并没有按照1、2、3、4、5 -> 100 的顺序进行?
2.最后 connection error: EOF 为何会存在?是Client代码不完善导致没有正确结束通信吗?
能不能帮忙给解释下。。。服务端的utils.Depack中如果没有Header怎么处理的?
如果第一次读到的是 header xxxx 123123123 header xxxx
第二次读到的是 123123123
这样子第二次的数据是不是会丢失了?
2017/09/25 20:54:17 127.0.0.1:49219 get message, keeping heartbeating...
2017/09/25 20:54:18 receive data string: {"meta":{"ID":"238","meta":"test"},"con
tent":{"meta":{"author":"nucky lu"},"content":"1506344058"}}
2017/09/25 20:54:18 echo the message: {"meta":{"ID":"238","meta":"test"},"conten
t":{"content":"1506344058","meta":{"author":"nucky lu"}}}
2017/09/25 20:54:18 127.0.0.1:49219 get message, keeping heartbeating...
2017/09/25 20:54:19 receive data string: {"meta":{"ID":"239","meta":"test"},"con
tent":{"meta":{"author":"nucky lu"},"content":"1506344059"}}
2017/09/25 20:54:19 echo the message: {"meta":{"ID":"239","meta":"test"},"conten
t":{"content":"1506344059","meta":{"author":"nucky lu"}}}
2017/09/25 20:54:23 127.0.0.1:49219 connection error: read tcp 127.0.0.1:1024-
127.0.0.1:49219: i/o timeout
2017/09/25 20:54:23 127.0.0.1:49219 get message, keeping heartbeating...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.