Sockets and threading

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Jul 12 17:34:41 EDT 2009


En Sun, 12 Jul 2009 16:16:29 -0300, zayatzz <alan.kesselmann at gmail.com>
escribió:

> 		while 1:
> 			k = self.myclntsock.recv(1)
> 			if k == "": break
> 			srvr.vlock.acquire()
> 			srvr.v += k
> 			srvr.vlock.release()
> 			self.myclntsock.send(srvr.v)
> 			self.myclntsock.close()
>
> Instead of sendint back i get this error :
>   File "server3.py", line 31, in serveclient
>     k = self.myclntsock.recv(1)
>   File "/usr/lib/python2.6/socket.py", line 165, in _dummy
>     raise error(EBADF, 'Bad file descriptor')
> socket.error: [Errno 9] Bad file descriptor
>
> As much as i understand this line 31 is supposed to recieve stuff from
> clients and has buffer size 1. I dont understand what this has to do
> with file descriptor.. whatever that is anyway.

That means the clntsock variable isn't an open, available socket. Note
that you close the socket right after sending the response - are you sure
you don't have an indentation error there?

-- 
Gabriel Genellina




More information about the Python-list mailing list