Python socket server craps out after receiving data
Question: I'm currently dabbling in sockets.  
I've got a jquery script that uses a very small flash swf file to establish a
true socket connection. As a server I'd like to use python.

Everything works, but I can only send information to the server just once.

I've tried 2 pieces of python code for the server.  
I guess since they both have the same problem the problem's not here.

    
    
    # TCP server example
    import socket
    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_socket.bind(("", 2000))
    server_socket.listen(5)
    
    print "TCPServer Waiting for client on port 2000"
    
    while 1:
            client_socket, address = server_socket.accept()
            print "I got a connection from ", address
            while 1:
                    data = client_socket.recv(512)
                    print "RECIEVED:" , data
    

Or this one:

    
    
    import socket
    mySocket = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
    mySocket.bind ( ( '', 2000 ) )
    mySocket.listen ( 1 )
    while True:
       channel, details = mySocket.accept()
       print 'We have opened a connection with', details
       print channel.recv ( 100 )
       channel.close()
    

On the client side I use <http://devpro.it/xmlsocket/>  
Sending a piece of data is as simple as executing

    
    
    xmls.send('some text');
    

Which arrives, but after that it stops working.

Does anyone know a solution? Or possibly a better javascript/swf combination I
could use?


Answer: I think you need to 'listen' again after you close the connection. Also,
Sockets deliver data as per the tcp specifications. You're not guaranteed to
get all of any data sent in one socket read. I see nothing to perform multiple
reads and assemble a complete 'message'

