Re: UDP 4 transefer file
From: David Schwartz (davids_at_webmaster.com)
Date: 01/10/04
- Next message: David Schwartz: "Re: strlen() +1 in write command?"
- Previous message: Samuel Walters: "Re: looking for a specific user who is "logged on""
- In reply to: Flex: "Re: UDP 4 transefer file"
- Next in thread: Flex: "Re: UDP 4 transefer file"
- Reply: Flex: "Re: UDP 4 transefer file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 9 Jan 2004 15:19:16 -0800
"Flex" <flexNONSPAMM@REfreemail.it> wrote in message
news:pan.2004.01.09.12.42.34.884450@REfreemail.it...
> Il Fri, 09 Jan 2004 07:49:31 +0000, Flex ha scritto:
>> Please help me,
>> I had to write , in a few days , a UDP protocoll to transfer files
>> between
>> 2 hosts (like TFTP).
>> I'd like to find documentation and example source code .
> I have not understood how can I send information like
> package number or checksum. I must send a record with several fields or
> to put in line
> these information in a header?
You should lay out each packet byte by byte. For example, you might use
a packet layout as follows:
Bytes 0 through 3, packet sequence number. Starts at zero and increments in
each packet. Unsigned 32-bit integer in network byte order.
Byte 4, packet type. Unsigned integer. Packet types are:
0: Header packet, gives total size of file, filename, and checksum
1: Data packet, contains data from the file
2: Acknowledgement packet, ackwnowledges receipt of packets
Then go on to define each packet type. Just remember, each side must
keep copies of each packet it has sent until they're acknowledged by the
other side. If too much time passes without an acknowledgement, back up and
start sending again from the first unacknowledged packet.
If you don't care about performance, then you can get really lazy --
just do this:
1) Send the next packet
2) Wait 250 milliseconds or until you receive a packet.
3) Did you receive an acknowledgement for the packet you sent? If no, go
back to step 1.
4) Send this packet again. Skip to step 2.
DS
- Next message: David Schwartz: "Re: strlen() +1 in write command?"
- Previous message: Samuel Walters: "Re: looking for a specific user who is "logged on""
- In reply to: Flex: "Re: UDP 4 transefer file"
- Next in thread: Flex: "Re: UDP 4 transefer file"
- Reply: Flex: "Re: UDP 4 transefer file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|