[Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

500: UDP theoretical question

Hi all,

I have heard that UDP is conectionless and that a connection is only made when sending data.
However, is it actually possible to create a connection with an UDP socket and hold that connection even if no data is to be sent for a little while i.e connect, wait few seconds then send data....?
The reason I ask is: I want PC1 to connect to PC2 and then after a few seconds, have PC2 to stream video to PC1.
Problem is: I can't make PC1 connect to PC2 straight off since PC2 has a non-routable ip address. With TCP, this is simple to achieve- make tcp socket connection from PC2 to PC1 then send data from PC2 to PC1. BUT can it be implemented with UDP????

Also, can a TCP client connect to UDP or does e.g to have a tcp connection then you need tcp socket on server side and client side?

Many thanks
  • 2
2 Solutions
TCP and UDP are two entirely different protocols... that doesn't mean you can't use both, but it's like me speaking in French to you, then trying to start a new conversation in Greek. Sure, both sides can understand both, but you can't use one to work with the other. So you'd end up with a TCP socket and a UDP socket.

With UDP, you'd have to keep sending dummy packets to have a "connection". Remember that UDP cannot keep track of your state.

So it may not really be worth it trying to take that approach.
To communicate using UDP there was no need to establish a connection prior to the data transmission.

Insted you can send a UDP packet with requiest msg from PC1 to PC2. Here PC2 has to listen on the UDP port for incomming request.
the PC2 can start sending data.

The other way is you can TCP to establish a connection from PC1 to PC2, the PC2 can send date to PC1.
but you cant use UDP on one end and TCP on the other end.

One other major thing.... there's not going to necessarily be an exact timeframe that you'll be able to pull off because of normal things over the internet.

If you ever look into how data flows in TCP/IP and compare it against UDP, you'll actually find it not to be very feasible to try to do that with UDP since you'd have to write a program that would keep track of all of this... it's almost like trying to reinvent TCP/IP.

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now