help using sockets, and OOP?
Dfenestr8
chrisdewinN0SPAM at yahoo.com.au
Sun Dec 5 16:45:34 EST 2004
On Sun, 05 Dec 2004 20:17:31 +0000, Jp Calderone wrote:
> Your problem doesn't seem to have anything to do with "OOP" (whatever
> that is). Rather, you are trying to use two blocking sockets at once.
>
> socket.connect() and socket.recv() are both "blocking" operations by
> default - they can take an arbitrary amount of time to return.
> Additionally, Botling.receiveData, one of your own functions, is also
> blocking: it will actually loop forever, never returning (until an
> exception blows it up). So execution of your program never even
> _gets_ to the "bert2 = ..." line. It's stuck running
> bert1.receiveData().
Ok, so what if I remove the while loop from the Botling class, and include
it in the __main__ ? Might this work as a solution then?
if __name__ == '__main__':
bert1 = Botling("^berty^", "#exciting", "irc.interesting.org")
bert2=Botling("^berty^", "#interesing", "irc.exciting.org")
bert1.connectBot()
bert2.connectBot()
while 1:
bert1.receiveData()
bert2.receiveData()
More information about the Python-list
mailing list