By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,587 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

creating a client socket udp and tcp...

P: n/a
AA
If I want to write the code, so... is everything same in both case (udp,
tcp) with the only difference of the .net Socket class constructor?

socketType
for udp: Dgram
for tcp: Stream

protocolType
for udp: Udp
for tcp: Tcp
Or there are many others things that change between tcp and udp .net
programming?
Thanks

Nov 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
No, there are other differences.

TCP is a connection-based protocol. That means that it does a lot of extra
work to make sure that your data gets through once and only once in the
correct order. It's easy to use and very reliable across varied conditions.

UDP is a datagram-based protocol. That means that you build a packet and
fire it off, never waiting to hear that it made it or that it was only
received once. As a result, using UDP is faster but less reliable due to the
missing overhead. If you want to be sure your data was received in the right
order (or at all), you have to a lot of extra work, which basically amounts
to building your own TCPish stack.

Some specific coding differences have to do with when you receive data. In
TCP, you receive streaming data which may or may not be chunked into the
packets used to send it. As a result, you need to do a level of buffering in
order to make sure you have an entire application-level packet (that's
specific based on your app's needs and implementation) before processing it.
UDP, on the other hand, gives you the exact packet it receives, so you know
that you have the whole thing (unless you broke it up on the other side).

Another receive aspect that's a little different has to do with the methods
use. TCP sockets generally use Receive() to read in bytes from the stream,
whereas UDP sockets generally use ReceiveFrom() because it also provides
source data, such as the host the packet came from. You can cross these
over, but it creates a different kind of mess.

Odds are you're better off using one or the other (and it's most likely TCP
is what will fit best).

Hope this is helpful.

"AA" <aa@personal.net.py> wrote in message
news:Om**************@TK2MSFTNGP11.phx.gbl...
If I want to write the code, so... is everything same in both case (udp,
tcp) with the only difference of the .net Socket class constructor?

socketType
for udp: Dgram
for tcp: Stream

protocolType
for udp: Udp
for tcp: Tcp
Or there are many others things that change between tcp and udp .net
programming?
Thanks

Nov 22 '05 #2

P: n/a
No, there are other differences.

TCP is a connection-based protocol. That means that it does a lot of extra
work to make sure that your data gets through once and only once in the
correct order. It's easy to use and very reliable across varied conditions.

UDP is a datagram-based protocol. That means that you build a packet and
fire it off, never waiting to hear that it made it or that it was only
received once. As a result, using UDP is faster but less reliable due to the
missing overhead. If you want to be sure your data was received in the right
order (or at all), you have to a lot of extra work, which basically amounts
to building your own TCPish stack.

Some specific coding differences have to do with when you receive data. In
TCP, you receive streaming data which may or may not be chunked into the
packets used to send it. As a result, you need to do a level of buffering in
order to make sure you have an entire application-level packet (that's
specific based on your app's needs and implementation) before processing it.
UDP, on the other hand, gives you the exact packet it receives, so you know
that you have the whole thing (unless you broke it up on the other side).

Another receive aspect that's a little different has to do with the methods
use. TCP sockets generally use Receive() to read in bytes from the stream,
whereas UDP sockets generally use ReceiveFrom() because it also provides
source data, such as the host the packet came from. You can cross these
over, but it creates a different kind of mess.

Odds are you're better off using one or the other (and it's most likely TCP
is what will fit best).

Hope this is helpful.

"AA" <aa@personal.net.py> wrote in message
news:Om**************@TK2MSFTNGP11.phx.gbl...
If I want to write the code, so... is everything same in both case (udp,
tcp) with the only difference of the .net Socket class constructor?

socketType
for udp: Dgram
for tcp: Stream

protocolType
for udp: Udp
for tcp: Tcp
Or there are many others things that change between tcp and udp .net
programming?
Thanks

Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.