[Tutor] Networking

Chris King g.nius.ck at gmail.com
Tue Oct 12 01:45:43 CEST 2010


  On 10/3/2010 7:20 PM, Chris King wrote:
>  On 10/2/2010 3:40 PM, Evert Rol wrote:
>>> Dear Tutors,
>>>      I have attached my 2 programs for networking. It uses socket 
>>> and SocketServer, but it just simplifies it even more. The problem 
>>> is it won't work. The Client raises the error, (with trace back)
>>> Traceback (most recent call last):
>>>    File "G:\My Dropbox\My Dropbox\Chris\Not done\client.py", line 
>>> 34, in<module>
>>>      print client.recv()
>>>    File "G:\My Dropbox\My Dropbox\Chris\Not done\client.py", line 
>>> 16, in recv
>>>      return self.__sock.recv(1024)
>>> error: [Errno 10053] An established connection was aborted by the 
>>> software in your host machine
>>> The server seems to get an error of some sort, but also seems to 
>>> catch and print it. It prints
>>> ----------------------------------------
>>> Exception happened during processing of request from ('127.0.0.1', 
>>> 1424)
>>> Traceback (most recent call last):
>>>    File "C:\Python26\lib\SocketServer.py", line 281, in 
>>> _handle_request_noblock
>>>      self.process_request(request, client_address)
>>>    File "C:\Python26\lib\SocketServer.py", line 307, in process_request
>>>      self.finish_request(request, client_address)
>>>    File "C:\Python26\lib\SocketServer.py", line 320, in finish_request
>>>      self.RequestHandlerClass(request, client_address, self)
>>> TypeError: 'NoneType' object is not callable
>>> ----------------------------------------
>>> I look at both of the documentations of socket and SocketServer, but 
>>> I couldn't firgue it out. I don't know much about networking. Please 
>>> Help
>> I don't know much about networking, less so about it on Windows; 
>> also, I've only scanned quickly through the server script, but I 
>> notice your create_handler() function doesn't return anything. I 
>> guess it needs to return the Handler class.
>> The example in the Python docs doesn't use a factory function, but 
>> instead directly puts the class as the second argument to TCPServer.
>> So the second argument needs to be a class, but since your 
>> create_handler() function returns nothing, you presumably get this 
>> NoneType exception.
>>
>>    Evert
>>
> Yeah, that could be a problem. It should return the class.
Now it won't send more than once. The Error the clients raises is:
Traceback (most recent call last):
   File "G:\My Dropbox\My Dropbox\Chris\Not done\client.py", line 34, in 
<module>
     print client.recv()
   File "G:\My Dropbox\My Dropbox\Chris\Not done\client.py", line 16, in 
recv
     return self.__sock.recv(1024)
error: [Errno 10053] An established connection was aborted by the 
software in your host machine
The server is blissfully unaware of its crashing clients, and keeps on 
going to help more clients to there dooms. The client can receive data 
multiple times, but just can send twice. Please help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101011/aba24ff2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: server.py
Type: text/x-python
Size: 2148 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20101011/aba24ff2/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: client.py
Type: text/x-python
Size: 1346 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20101011/aba24ff2/attachment-0001.py>


More information about the Tutor mailing list