我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

转到服务器:获取非空net.Conn

I have server with several net.Conn. How can I get list of net.Conn which have unreaded messages (without using active waiting) ?

I don't think you can.

If you try to read from the net.Conn with its Read method, it will block until there is data. So just start a goroutine for each net.Conn, and read from it in the goroutine.

The example in the net package's documentation does exactly that: https://golang.org/pkg/net/#example_Listener

近期文章

  • 此文字的类型是什么?
  • Golang不会重新编译某些文件
  • 查找一个单词是否为另一个的复数
  • 使用JSON从巨大的字符串中解码少量数据
  • 包装类型的惯用方式是什么?
  • 无法返回数据库对象。
  • 如何在Go包和文件夹中构造代码?
  • 从字节数组创建结构
  • 重新创建由Request.Write保留的http.Request
  • 关于golang HandlerFunc。 我预计找不到404,但
  • 带有Go Parse Json响应的Api请求
  • 在进行中,什么是json.Unmarshal最大深度?
  • 在Go中为多类型数组创建通用函数
  • Golang-具有json接口的结构
  • 是否等效于PHP的pack()?
  • 转到:为什么time.Now()。Hour / Minute / Second返回六位数?
  • 在Go中测试构造函数
  • 为什么不使用锁来同步日志包
  • 在goroutine中将字符串写入文件
  • 以字符串开头的结构字段名称

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华