[Tutor] Socket Programming

Navneet rocklearnpython at gmail.com
Fri Jan 27 20:53:39 CET 2012


On 1/26/2012 4:22 PM, Navneet wrote:
> Hi,
>
> I am trying to create a chat program.(Programs are attached)
> Please find the code below, where I am having the problem.
>
> def run( self ):
>     while 1:
>             print "Hello There !!!!"
>         print self.descriptors
>         # Await an event on a readable socket descriptor
>             (sread, swrite, sexc) = select.select( self.descriptors, 
> [], [] )
>         print sexc
>             # Iterate through the tagged read descriptors
>         print sread
>             print "Hello There 1 !!!!"
>         for sock in sread:
>
>
> For this I am getting the output as below:
> bash-3.1$ python Server.py
> Enter the Port:...9009
> ChatServer started on port 9009
> Hello There !!!!
> [<socket._socketobject object at 0x0000000002487660>]
>
>
> But it is not printing the value of sread or "Hello There 1 !!!!!"
>
>
>
>
>
Hello All,

One more thing I want to add here is, I am trying to create the GUI 
based chat server.(Attached the programs.)
The concept is something like this:
I will start a server on a particular port and different Clients can 
interact with each other using that (more like a chat room )
Now I want to add the GUI part in a different module and want to call 
that module from client program.
But while executing the client1.py I am getting below error :



bash-3.1$ python Client1.py
Enter the server address:...9009
Traceback (most recent call last):
   File "Client1.py", line 53, in <module>
     c = ClientChat(serverport)
   File "Client1.py", line 24, in __init__
     gui.callGui()
   File "a:\FedEx\Exp\ClientGui.py", line 37, in callGui
     sendbutton =Button(f2, width = 5, height = 2, text = "Send", 
command = C.ClientChat.senddata())
TypeError: unbound method senddata() must be called with ClientChat 
instance as first argument (got nothing instead)












-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120127/df8a7055/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Client1.py
URL: <http://mail.python.org/pipermail/tutor/attachments/20120127/df8a7055/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ClientGui.py
URL: <http://mail.python.org/pipermail/tutor/attachments/20120127/df8a7055/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Server.py
URL: <http://mail.python.org/pipermail/tutor/attachments/20120127/df8a7055/attachment-0002.ksh>


More information about the Tutor mailing list