Last active
January 7, 2016 12:47
-
-
Save etipton/7a86a922feb9922b0cf8 to your computer and use it in GitHub Desktop.
Ruby TCP server, port 2000
This file contains 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
#!/usr/bin/env ruby | |
require 'socket' | |
server = TCPServer.new(2000) | |
loop do | |
sock = server.accept | |
# sleep 6 # if you want to test timeouts | |
# puts sock.recvmsg[0] # if you want to test receiving request data | |
# sock.sendmsg("monkey") # if you want to test sending response data | |
# if you want to simulate ECONNRESET | |
# linger = [1,0].pack('ii') | |
# sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, linger) | |
sock.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
written / tested using ruby 2.2.2