Created
April 28, 2017 18:43
-
-
Save bararchy/7c38004902d7e1b1363f14da5d7a1136 to your computer and use it in GitHub Desktop.
sockets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "socket" | |
spawn do | |
sock = TCPSocket.new("google.com", 443) | |
loop do | |
allocate_mem = Slice(UInt8).new(10) | |
size = sock.read(allocate_mem) | |
puts "#{allocate_mem[0, size]}" | |
puts "Socket is dead" if sock.closed? | |
end | |
end | |
sleep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment