Problem with TCP Network Programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yukijocelyn
    New Member
    • Aug 2007
    • 4

    #1

    Problem with TCP Network Programming

    Hi

    I am currently programming a TCP socket to transfer large files. My client is running on .NET application and my server is running on Java.

    I am using TCP socket to transfer file over the network, and I am able to achieve it only if I segment my own file and then send them over the network one segment by one segment. I would like to ask that why do I have to do this when TCP is able to help me handle the whole large file. I thought that TCP can automatically segment and send the file, and in sequence, with error checking capabilities. However in this network programming, that I did, whenever I put a large file for the TCP sockets to transfer, it will only transfer the first time, which is the size that the network can handle. The rest are lost.

    My .NET application is using the Socket.Send(byt e array) while my Java server that is receiving the byte array using DataInputStream .read(byte array).

    Can anyone explain to me why in this case TCP is behaving like it is UDP? I did set the protocol type of both the client and server to be using TCP.

    Thank you!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Well the Send() functions return an integer value for a reason. It tell yous how much of the data was sent, so you can loop through and continue to send the data from where it left off.
    This is a normal operation.
    You can't expect to just dump a 10meg file in continuous memory and have it all go through the socket.

    Comment

    Working...