dousui6488 2016-07-03 18:36 采纳率: 100%
浏览 204
已采纳

作为读取消息的服务器,您如何确定消息的长度?

I'm programming a server that accepts an incoming connection from a client and then reads from it (via net.Conn.Read()). I'm going to be reading the message into a []byte slice obviously and then processing it in an unrelated way, but the question is - how do I find out the length of this message first to create a slice of according length?

  • 写回答

3条回答 默认 最新

  • douce1368 2016-07-07 15:14
    关注

    In the end what I did was create a 1024 byte slice, then read the message from the connection, then shorten the slice to the number of integers read.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真