Skip to content

Instantly share code, notes, and snippets.

@ChunChunMorning
Last active December 5, 2016 00:51
Show Gist options
  • Save ChunChunMorning/3fbc731c412adcc6591f9c22e4b85680 to your computer and use it in GitHub Desktop.
Save ChunChunMorning/3fbc731c412adcc6591f9c22e4b85680 to your computer and use it in GitHub Desktop.
require "socket"
server = TCPServer.open("127.0.0.1", 50000);
puts "Server is running at 50000."
socket = server.accept();
socket.write("welcome\n");
loop {
message = socket.gets();
if (message.nil?())
break;
end
puts("socekt: " + message);
socket.write(message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment