[Tutor] Sockets -- huh?

D-Man dsh8290@rit.edu
Fri, 23 Mar 2001 12:03:11 -0500


Have you tried telnetlib?

>>> import telnetlib
>>> conn = telnetlib.Telnet()
>>> conn.open( "harmony.cs.rit.edu" )
>>> print conn.read_until( "login:" , 10 )
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!             -- Department of Computer Science at RIT --              !!
!!                                                                      !!
!! All activity may be logged or monitored. Unauthorized connections    !!
!! are prohibited. Disconnect immediately if you object to this policy. !!
!!                                                                      !!
!! As of June 2001 telnet will no longer be available. Please use ssh.  !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
harmony.cs.rit.edu
login:
>>>


I tried with the ip address you gave,  it worked for plain telnet (ie, the 'telnet' program that is part of windows or cygwin (I don't know which is first in path)).  When I tried using python, sometimes I got various other messages at different times:

Failed to detect protocol...


Telnet connection detected.

Only one connection is allowed for a single IP address.


HTH,
-D

On Thu, Mar 22, 2001 at 10:54:17PM -0500, JRicker wrote:
| Decided to learn about sockets and python.  The object of my desire so
| to speak would be a helper program for a game called Tradewars.  Used to
| be played on alot of BBSs back when they were more prevalent and now
| several servers are running it.  I'm trying to telnet in if that makes a
| difference.  I started small and simple:
| 
| import socket
| 
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
| try:
|     s.connect(("216.211.84.44", 23))
| except Exception, e: print e
| 
| s.send("\n\n") # this line was added after the rest, hoping to get a
| response.
| 
| test = s.recv(1024)
| s.close()
| print test
| 
| but test isn't printing anything out.  I'm expecting to get at least:
| 
| Telnet connection detected.
| 
| Please enter your name (ENTER for none):
| 
| I know that at least a connection is being made because while my script
| was running, I tried logging in with telnet.  The server only allows one
| connection from any one IP address and it denied me entrance until the
| script finished running.
| 
| Any thoughts?
| 
| Thanks
| Joel