Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending packets over network

Status
Not open for further replies.

millzy7

Programmer
Dec 9, 2003
96
US
Hi,

If you send data over a network and it is broken into packets, is there a set size for each packet? Does it depend on the type of network being sent across?

Thanks

Millzy
 
You can use System.Net.Sockets namespace (TcpListener and TcpClient) for example.
However, you cannot enforce the packet size if you want a large packet because the lower TCP layers will break it into smaller pieces (fragmentation) in order to be transmitted accros the network (further fragmentation of the already fragmented packets can occur if they need to cross the network borders and the MTU of the other network is smaller then the MTU of your network.
And usually you cannot control the packet's size [wink]...

MTU = Maximum Transfer Unit (which can differ from a subnetwork to another) and its maximum size is (64KBytes - <size of the TCP/IP pachet header>).
 
If i'm sending a byte array across with the text "Testing" in it, is there a possiblity that it will be broken into more than one packet?
 
If i'm sending a byte array across with the text "Testing" in it, is there a possiblity that it will be broken into more than one packet?
Almost certainly.

If you're depending on a fixed message size, you will need to transmit the size of the message as the first thing sent. The recipient would then be able to know how many bytes to expect to receive. In any case, the recipient needs to be able to combine multiple packets in order to re-form the original data.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top