Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Simple TCP 2: loading, sending, receiving and saving streams

KoppisKoppis Member Posts: 68
Hi. I am using SimpleTCP2 components to send text and files via internet. I have succeeded sending text and a picture, but only because I knew what kind of information was coming. So this is the problem.

I want to make program, that can send and receive files. I noticed that SimpleTCP2 sends the stream in little pieces and I don't even know when it is fully received.

If you could advice me how to:
1) Send File of any size from client to server
2) Receive the file on server and IF it is bitmap or jpg, then save it also.

I believe I will find out rest if you guid me in the beginning.

Comments

  • zibadianzibadian Member Posts: 6,349
    : Hi. I am using SimpleTCP2 components to send text and files via internet. I have succeeded sending text and a picture, but only because I knew what kind of information was coming. So this is the problem.
    :
    : I want to make program, that can send and receive files. I noticed that SimpleTCP2 sends the stream in little pieces and I don't even know when it is fully received.
    :
    : If you could advice me how to:
    : 1) Send File of any size from client to server
    : 2) Receive the file on server and IF it is bitmap or jpg, then save it also.
    :
    : I believe I will find out rest if you guid me in the beginning.
    :
    If you can control both the client and the server, the solution is quite simple. First send a string or integer detailing the type of file. Then send the file itself. This way the server knows what to do with it.
    Otherwise, you can scan the header of the file for the type. You can find the specifics on the internet when searching jpg-file format (or something similar). Based on several jpg-files, I think that the first three bytes are #FF#D8#FF ().
  • KoppisKoppis Member Posts: 68
    : : Hi. I am using SimpleTCP2 components to send text and files via internet. I have succeeded sending text and a picture, but only because I knew what kind of information was coming. So this is the problem.
    : :
    : : I want to make program, that can send and receive files. I noticed that SimpleTCP2 sends the stream in little pieces and I don't even know when it is fully received.
    : :
    : : If you could advice me how to:
    : : 1) Send File of any size from client to server
    : : 2) Receive the file on server and IF it is bitmap or jpg, then save it also.
    : :
    : : I believe I will find out rest if you guid me in the beginning.
    : :
    : If you can control both the client and the server, the solution is quite simple. First send a string or integer detailing the type of file. Then send the file itself. This way the server knows what to do with it.
    : Otherwise, you can scan the header of the file for the type. You can find the specifics on the internet when searching jpg-file format (or something similar). Based on several jpg-files, I think that the first three bytes are #FF#D8#FF ().
    :
    I think I will change the components code and add the file-info to the beginning of the package and send it then. Thx for tip, I will try to make use of it.

Sign In or Register to comment.