【发布时间】:2023-11-08 13:54:01
【问题描述】:
我正在使用 GServer 和 TCPSocket 开发一个 Ruby TCP 客户端/服务器应用程序。我遇到了一个我不明白的问题。我的 TCPSocket 客户端成功连接到我的 GServer,但我只能使用 puts 发送数据。对 TCPSocket.send 或 TCPSocket.write 的调用什么都不做。是不是我缺少什么魔法?
tcp_client = TCPSocket.new( ipaddr, port )
tcp_client.puts( 'Z' ) # -> GServer receives "Z\n"
但如果我使用 write 或 send...
tcp_client = TCPSocket.new( ipaddr, port )
tcp_client.write( 'Z' ) # -> nothing is received
tcp_client.send( 'Z' ) # -> nothing is received
感谢您的帮助
附加信息:
- Linux 和 Windows 上的行为相同。
- 写入后刷新套接字不会改变行为。
【问题讨论】: