When windows client send a file (about 150kb) to linux server, after about 40kb is sent they are blo

Discussion in 'Linux Networking' started by alones, Aug 22, 2007.

  1. alones

    alones Guest

    I encounted a simlar problem like following problem (Unfortunately,
    there was no answer...)
    http://groups.google.com/group/comp...nux+send+file+problem&rnum=5#71ad745605f2b5ac
    Thoguth I myself found the solution, I could not understand it. So I
    post this.

    The problem is as followings,

    * Windows client
    step1. socket is crated with SOCK_STREAM, IPPROTO_TCP options
    step2. connect()
    step3. open a file which size is about 150kb
    step4. send piece (255byte) of file in while loop (with 200 ms sleep)

    * Linux server
    step1. both listen and accept socket is created with SOCK_STREAM, 0
    options
    step2. bind, listen, accept (when window client connect)
    step3. create file and write received piece of file from windows
    client

    * Result
    Windows client rightly connected to linux server and began to send
    piece of file to linux server.
    But after sending 42075 byte, both client and server were blocked. -
    _-;;

    With same source code of both server and client, in case of window-
    window, the file is successfuly transferred.

    * Soluction
    After windows client connect to linux server, I set SO_RCVBUF to
    client socket (not SO_SNDBUF) as followings,
    int tmp = 819200;
    m_pChildSock->set_sockopt(SOL_SOCKET, SO_RCVBUF, (char*)&tmp,
    sizeof(tmp));

    As result, window client could successfuly send the file to linux
    server.

    ¡Ø I tried to set SO_SNDBUF to socket, and after before window client
    connect to linux server, change send/receive buff size of linux
    server. and chang the sleep interval of client.
    All of above try were failed.
    And the size of received buff should bigger than the size of file to
    send.

    Why after set receive buff size to client socket, the transfer
    succeed???
     
    alones, Aug 22, 2007
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.