Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. UDP socket

UDP socket

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nahitan
    wrote on last edited by
    #1

    Hi there, I working on an application that uses UDP socket to transfer data, how can I make sure if there is a connection problem? for TCP I get socket connection errors but for UDP, I do not get any error and I need a way to make sure the connection is up or be notified that there is no connection. Regards,

    M E M 3 Replies Last reply
    0
    • N nahitan

      Hi there, I working on an application that uses UDP socket to transfer data, how can I make sure if there is a connection problem? for TCP I get socket connection errors but for UDP, I do not get any error and I need a way to make sure the connection is up or be notified that there is no connection. Regards,

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      It's all up to you to determine whether UDP datagrams get sent and arrive at the other end. TCP/IP does that for you, which is why it's able to report connection errors. There's no "connection" with UDP, so it's not possible to have a connection error. Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      1 Reply Last reply
      0
      • N nahitan

        Hi there, I working on an application that uses UDP socket to transfer data, how can I make sure if there is a connection problem? for TCP I get socket connection errors but for UDP, I do not get any error and I need a way to make sure the connection is up or be notified that there is no connection. Regards,

        E Offline
        E Offline
        Eytukan
        wrote on last edited by
        #3

        Make an occassional "pulse" check of the clients, send pulse ACKs from the clients. Write some algo to check if the packets did get assemble at the right order. Make a protocol that takes care of these issues and retransmit the lost/unorderd ones, there you go! You've got TCP on hand :P


        OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]

        modified on Wednesday, March 12, 2008 12:43 PM

        1 Reply Last reply
        0
        • N nahitan

          Hi there, I working on an application that uses UDP socket to transfer data, how can I make sure if there is a connection problem? for TCP I get socket connection errors but for UDP, I do not get any error and I need a way to make sure the connection is up or be notified that there is no connection. Regards,

          M Offline
          M Offline
          Moak
          wrote on last edited by
          #4

          Hi there, it is possible to use connected UDP sockets, however the information you get is limited. Using connect on a UDP socket (it will not cause any network traffic) together with send (instead of the usual sendto) allows you to get asynchronous error information... e.g. 'connection refused' if the target peer is not listening on given UDP port. It is pretty much limited to that. I am not sure what kind of "connection problems" you wish to detect, but UDP is not very reliable and if you want to make sure that no data is lost or recover from temporary network outages you need to write your own protocol to detect/correct such cases. As a short note, TCP provides this and more for free. :) /M

          My Webchat

          N 1 Reply Last reply
          0
          • M Moak

            Hi there, it is possible to use connected UDP sockets, however the information you get is limited. Using connect on a UDP socket (it will not cause any network traffic) together with send (instead of the usual sendto) allows you to get asynchronous error information... e.g. 'connection refused' if the target peer is not listening on given UDP port. It is pretty much limited to that. I am not sure what kind of "connection problems" you wish to detect, but UDP is not very reliable and if you want to make sure that no data is lost or recover from temporary network outages you need to write your own protocol to detect/correct such cases. As a short note, TCP provides this and more for free. :) /M

            My Webchat

            N Offline
            N Offline
            nahitan
            wrote on last edited by
            #5

            Thanks for the reply, The problem is that we have some wireless mobile devices that are talking to a windows application via UDP sockets using SIM card (GPRS), sometimes the mobile device can not send any message to the application and the application does not know if the socket is down or not! I need to get notified in my application about the network issue (socket disconnection...) thanks,

            M 1 Reply Last reply
            0
            • N nahitan

              Thanks for the reply, The problem is that we have some wireless mobile devices that are talking to a windows application via UDP sockets using SIM card (GPRS), sometimes the mobile device can not send any message to the application and the application does not know if the socket is down or not! I need to get notified in my application about the network issue (socket disconnection...) thanks,

              M Offline
              M Offline
              Moak
              wrote on last edited by
              #6

              Unfortunately, this information is not provided with UDP. You need to implement a heart beat (or use an existing library that does it for you). Maybe you can implement a simple solution where the Windows application will mark any mobile device "disconnected" which hasn't sent anything within a time intervall. The next time the mobile device sends something it will be marked "connected" again. Hope it helps!

              My Webchat

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups