Ken D'Ambrosio
2018-06-30 01:00:07 UTC
Hi! I'm trying to read a character-at-a-time off a network socket;
while (say) getch kinda-sorta does that, it only does it once the remote
end has submitted the entire line via <CR>. Clearly, I'm missing
something where character-at-a-time interaction could occur.
Any pointers?
Thanks!
-Ken
E.g., "character-at-a-time," but only when <CR> is submitted:
require 'socket'
server_socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
pry(main)> sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
server_socket.bind( sockaddr )
server_socket.listen(5)
client, client_sockaddr = server_socket.accept
while (foo = client.getc)
puts foo
end
Unsubscribe: <mailto:ruby-talk-***@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
while (say) getch kinda-sorta does that, it only does it once the remote
end has submitted the entire line via <CR>. Clearly, I'm missing
something where character-at-a-time interaction could occur.
Any pointers?
Thanks!
-Ken
E.g., "character-at-a-time," but only when <CR> is submitted:
require 'socket'
server_socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
pry(main)> sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
server_socket.bind( sockaddr )
server_socket.listen(5)
client, client_sockaddr = server_socket.accept
while (foo = client.getc)
puts foo
end
Unsubscribe: <mailto:ruby-talk-***@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>