none
UDP connection lost ? RRS feed

  • Question

  • How can i come to know client is disconnected from server,even though udp is a connectionless?

    Coding.....................................

    Friday, December 13, 2019 10:32 AM

Answers

  • As it is connectionless there is no connection and so no disconnection. The only thing I can think of is that other end (client) send something that tells the other end (server) that work has been completed for now.

    • Marked as answer by La07K Monday, December 16, 2019 5:18 AM
    Friday, December 13, 2019 11:01 AM
  • I want to magnify MasaSam's answer, which is quite correct.

    Every UDP packet transaction stands alone.  There is no connection, and there is no state.  In that respect, you can't  even think about "client" and "server" for UDP.  There are just senders and receivers, and they are peers.

    A sender has no way to know whether a UDP packet was received.  That's the way the protocol is designed.  There is no feedback, and it's not considered an error.  Many UDP senders just broadcast in case someone is listening.  If you need to know whether your packet was received, then you should be using TCP.  That's what it's for, and TCP does have clearly defined "server" and "client" roles.

    It is possible, as MasaSam said, for you to implement two-way communication, so the listener can tell the sender that the packet was received.  That response is, however, another independent packet.  You'll have to figure out on your own how to identify which packet was received.

    But that's a silly thing to do, since TCP already does all of that as part of its design.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    • Marked as answer by La07K Monday, December 16, 2019 5:18 AM
    Friday, December 13, 2019 10:58 PM

All replies

  • As it is connectionless there is no connection and so no disconnection. The only thing I can think of is that other end (client) send something that tells the other end (server) that work has been completed for now.

    • Marked as answer by La07K Monday, December 16, 2019 5:18 AM
    Friday, December 13, 2019 11:01 AM
  • I want to magnify MasaSam's answer, which is quite correct.

    Every UDP packet transaction stands alone.  There is no connection, and there is no state.  In that respect, you can't  even think about "client" and "server" for UDP.  There are just senders and receivers, and they are peers.

    A sender has no way to know whether a UDP packet was received.  That's the way the protocol is designed.  There is no feedback, and it's not considered an error.  Many UDP senders just broadcast in case someone is listening.  If you need to know whether your packet was received, then you should be using TCP.  That's what it's for, and TCP does have clearly defined "server" and "client" roles.

    It is possible, as MasaSam said, for you to implement two-way communication, so the listener can tell the sender that the packet was received.  That response is, however, another independent packet.  You'll have to figure out on your own how to identify which packet was received.

    But that's a silly thing to do, since TCP already does all of that as part of its design.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    • Marked as answer by La07K Monday, December 16, 2019 5:18 AM
    Friday, December 13, 2019 10:58 PM
  • The other problem with UDP is that only one process on each computer can be listening to a particular port.  With TCP, I can have many applications connect to a TCP server and receive packets.

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Friday, December 13, 2019 11:00 PM
  • Thanks Robert:)

    Coding.....................................

    Monday, December 16, 2019 5:18 AM
  • Thanks MasaSam:)

    Coding.....................................

    Monday, December 16, 2019 5:18 AM