Created
September 25, 2011 15:20
-
-
Save stenno/1240714 to your computer and use it in GitHub Desktop.
Connecting to nethack.eu via ruby and socket
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
require 'socket' | |
$TELNET_BUFFER = 4096 | |
class Connection | |
attr_reader :neusock | |
def self.init | |
@neusock = TCPSocket.new("nethack.eu", 23) | |
handshake = [0xff, 0xfb, 0x18, 0xff, 0xfa, 0x18, 0x00, 'x', 't', 'e', 'r', 'm', 0xff, 0xf0, 0xff, 0xfc, 0x20, 0xff, 0xfc, 0x23, 0xff, 0xfc, 0x27, 0xff, 0xfe, 0x03, 0xff, 0xfb, 0x01, 0xff, 0xfd, 0x05, 0xff, 0xfb, 0x21, 0xff, 0xfb, 0x1f, 0xff, 0xfa, 0x1f, 0x00, 0x50, 0x00, 0x18, 0xff, 0xf0] | |
#from https://github.com/canidae/saiph/blob/master/src/Telnet.cpp | |
handshake = handshake.map{|c| c.class == Fixnum ? c.chr : c}.join | |
@neusock.print handshake | |
@neusock.recv $TELNET_BUFFER #discard that shit! | |
@neusock.print "l" | |
return @neusock.recv $TELNET_BUFFER | |
end | |
end | |
puts Connection.init #gibt mir den login-screen von nethack.eu zurueck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment