Skip to content Skip to sidebar Skip to footer

Using Cmd Module With A Socket

I've been having a hard time getting the CMD module to use a socket for stdin. Here is what I have : class Server(cmd.Cmd): use_rawinput = False def __init__(self, port):

Solution 1:

The file returned by makefile will only work for SOCK_STREAM sockets. SOCK_DGRAM sockets have no notion of a continuous stream of bytes (only individual packets), and therefore cannot use read or write.

You should initialize the socket with socket.SOCK_STREAM instead of socket.SOCK_DGRAM.

Post a Comment for "Using Cmd Module With A Socket"