UDP socket
-
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,
-
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,
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:
-
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,
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
-
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,
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 withsend
(instead of the usualsendto
) 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 -
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 withsend
(instead of the usualsendto
) 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. :) /MThanks 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,
-
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,
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!