Skip to content

Instantly share code, notes, and snippets.

@bararchy
Created April 28, 2017 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bararchy/7c38004902d7e1b1363f14da5d7a1136 to your computer and use it in GitHub Desktop.
Save bararchy/7c38004902d7e1b1363f14da5d7a1136 to your computer and use it in GitHub Desktop.
sockets
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