473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

creating a client socket udp and tcp...

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
2 4681
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Dee | last post by:
Is C++ the best language to create a Windows based Instant Messenger? Something along the lines of MSN Messenger, ICQ, Yahoo Chat, etc? Are there any downloadable full or trial SDK's out there?...
15
by: Michael Rybak | last post by:
hi, everyone. I'm writing a 2-players game that should support network mode. I'm now testing it on 1 PC since I don't have 2. I directly use sockets, and both client and server do...
2
by: kernel.lover | last post by:
Hello, I have UDP socket programs. I want to run server socket on one machine and client socket on another and viceversa. How can i create a flexibility at each system so that it will not only...
4
by: SH | last post by:
I wish to create a program (really a Windows Service) that sits and waits for a client PC to communicate with it, but I can't come up with a good method of doing so. I want to have a service...
2
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe Connections once established will not be closed unless...
4
by: newlearner | last post by:
Hi, I wrote a socket program to pass message form client and server. This is a test case and to be inplemented in the later stage. In my test case the connection between the server and the...
0
by: dheberger | last post by:
I have an application that is a client. The client connects to a host who sends data to the client every n seconds. My client connection is only receiving the first data dump. Also I never seem to...
6
by: 7stud | last post by:
My question pertains to this example: #!/usr/bin/env python import socket, sys, time host = sys.argv textport = sys.argv s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
1
by: alex21 | last post by:
Ok i have never before tried networking in my programming, so this is the first time i have tried anything like this. But i am trying to make an application which acts as a medium between a server...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.