0

the process blocked at the established even after client socket write something and manually flush it unless the client socket close

server = TCPServer.new 2000 # a simple socket server                                                     

socket = server.accept                                                          

puts "socket established"                                                   
msg = socket.read                                                         
puts "type: #{msg.class} content: #{msg}"                                                                                                       

socket.close 
4

1 回答 1

0
  1. 套接字编程中没有“EOF 字符”。
  2. 当对等方关闭连接时,结束。它通过read()返回各种 API 相关值向应用程序发出信号。
于 2013-05-06T10:15:16.750 回答