Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    18
    ReputationRep:
    How do you properly transfer files via TCP?

    The problem is that because TCP is essentially a stream of bytes you don't know when you have received the whole file. You could close the tcp connection and reopen but that seems rather inefficient.

    You could also send (before the actual file) a separate TCP message stating the file length and therefore the transferee will know when has received the whole file. Problem is that you face the same problem. How do you know when your file length message ends and your actual file begins?

    So how exactly is it done?
    Offline

    14
    ReputationRep:
    You could know when your file length message ends because you could make it a fixed length. For a file length you only need 8 bytes, so you read the first 8 bytes from the stream, and then that tells you how many more bytes you need to read from it.
    Offline

    1
    ReputationRep:
    tcp is just a way of handling data over the network in a way that the packets can be put back into the same order they were sent and with some level of checking that the data has reached the other end. There's nothing within TCP that says what the data is or what to do with it.

    You then put a protocol on top of TCP to send the required type of data, This could be HTTP (for web traffic), SSH/RDP (for interactive logins) or FTP/SMB/NFS for file transfer. What goes into that protocol depends on what it needs to do.
    • Thread Starter
    Offline

    18
    ReputationRep:
    Yeh, I was just wondering how FTP is implemented with TCP regarding what I said above.
    Online

    20
    ReputationRep:
    Have you tried RFC959 for a description of the protocol and looking at gnu sources for an example implementation?
    • Thread Starter
    Offline

    18
    ReputationRep:
    (Original post by Joinedup)
    Have you tried RFC959 for a description of the protocol and looking at gnu sources for an example implementation?
    Nope.
    Offline

    1
    ReputationRep:
    (Original post by beepbeeprichie)
    Nope.
    for a lot of common protocols the rfc documents are the place to look for how they work. Often there's more than one rfc for a protocol as things have been added.
 
 
 
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    Has a teacher ever helped you cheat?
    Useful resources
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Write a reply...
    Reply
    Hide
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.