[Tutor] Looking for some constructive peer review.
Luke Paireepinart
rabidpoobear at gmail.com
Fri Nov 10 08:00:16 CET 2006
Chris Hengge wrote:
> I write this little IM style client the other night based on some
> sample socket and threading examples I found plus a little of my own
> twist just to make it more interesting..
> I'd like some constructive peer review just to help me make sure I'm
> doing this correctly / well.
>
> You can test it by connecting to localhost if you want to run the code
> to help with review. One thing I'd like to know how to do is fix the
> output to the screen. Currently it interrupts typing when a message is
> recieved which as I understand is because my typing a line is
> basically letting the client thread sleep, and recieving a message
> triggers the server thread while I'm typing... Maybe there is some
> sort of better thread management for this? Or is this just a limiting
> factor since I'm playing in the console world? The other issue I have
> is when the other person types DSC to end their session, I should be
> able to put the thread to sleep, or trash it or something so I dont
> have to close the app to use it again. It also isn't going through the
> entire
>
> I was hoping to actually make something more like an IRC server /
> client, but I'm not sure I've got this thing down well enough to try
> that. Thanks!
Sorry, I'm too tired to read your code right now.
A few things I'd like to point out...
yeah, it's tough to show output and get input in the same console
window. A simple TKInter gui would not be all that hard to put together.
Just a textbox and an entry widget.
wouldn't even need a 'send' button if you just bind 'enter' to the send
command from the entry widget.
Also, IRC is not as complicated as you may think. The messages are all
in ascii.
Basically you just say
import socket
sock = socket.socket()
sock.connect(('irc.freenode.net',6667))
sock.send("NICK Bob\r\n")
sock.send("USER Bob irc.freenode.net bla :realname\r\n")
sock.send("JOIN #test\r\n")
sock.send("PRIVMSG #test HELLO!\r\n")
sock.send("LEAVE #test\r\n")
More information about the Tutor
mailing list