#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    6
    Rep Power
    0

    Problems with Large files over Python Sockets


    I have implemented a small filesharing system with a client and server side, that works by the client connecting to the server and requesting a file, the server then attemtps to reconnect to the client on a client specified port. If that connection fails it goes back and sends on the orriginal connection. The server simply uses a s.sendall(file) to send teh data, and the client uses:
    while 1:
    data = conn.recv(1024)
    if not data: break
    f.write(data)
    to recieve the data.

    This works great for files up to 10megs, however I recently tried with a 60 meg file, and got a server side
    "socket.error (10055, "not enough buffer space')" error

    any ideas???

    thanks so much
    brad
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    14
    From the python docs:
    send( string[, flags])
    Send data to the socket. The socket must be connected to a remote socket. The optional flags argument has the same meaning as for recv() above. Returns the number of bytes sent. Applications are responsible for checking that all data has been sent; if only some of the data was transmitted, the application needs to attempt delivery of the remaining data.

    sendall( string[, flags])
    Send data to the socket. The socket must be connected to a remote socket. The optional flags argument has the same meaning as for recv() above. Unlike send(), this method continues to send data from string until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully sent.
    So, just repeat send() until they get the whole thing. sendall() isn't guaranteed to send it all without error, and if it does error (as you saw), it can't tell you how much it sent.
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.

IMN logo majestic logo threadwatch logo seochat tools logo