Socket MUD client script

MRAB python at mrabarnett.plus.com
Fri Oct 30 15:12:26 EDT 2009


Zamnedix wrote:
> I'm having trouble with this script I'm writing. I want it to connect
> to a MUD, which it does fine, but afterwards it displays the greeting
> and login prompt, and when I type in username the loop to receive and
> then send seems to stop.
> 
> 
> Here's my code:
> 
> #!/usr/bin/python
> import socket
> import sys
> a = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> address = str(raw_input("HOST:PORT > "))

'raw_input' returns a string, so there's no need to use 'str'.

> address = address.split(":")
> a.connect((address[0], int(address[1])))
> print "CONNECTED"
> while 1:
>    print a.recv(4079)
>    print a.recv(4079)
>    msg = str(raw_input("MSG > "))
>    a.sendall(msg)
[snip]

It might be expecting the string to end with '\n' or '\r\n'.




More information about the Python-list mailing list