|
-
May 5th, 2004, 10:46 AM
#1
Socket
A quick question about socket.
I've got an network application that works fine under normal circumstances and Im now trying to add a bit of error checking.
The procedure for starting up the network connection:
(using udp) :
Code:
if( !AfxSocketInit() )
return ERROR;
if (ASyncSocket::Create(port, SOCK_DGRAM, FD_READ) == 0)
return ERROR;
and then it's ready to use both sendto and OnReceive methods.
If I then disable the network devices (in control panel->system->device manager) and unplug the network cable from my laptop the program still works fine. How is it possible to check if the network device is enabled\working?
Appreciate any response.
-
May 5th, 2004, 10:55 AM
#2
Use TCP
Usually when using UDP, you do not care - packets can get lost whenver they "want".
If you do care for the other side still being present, use either TCP or set up a protocol yourself on top of UDP whicks checks (by sending periodically data and checking the repsonse with a timeout) if the "connection" still is ok.
So it's a question of design.
The Saviour of the World is a Penguin and Linus Torvalds is his Prophet.
-
May 5th, 2004, 11:01 AM
#3
I think you misunderstood my problem, it's not a matter of sending or receiving data. I'd like to display an error message to the user if the network on his\her computer is not working or disabled or not installed when starting up the networking application. I though by disabling the networking device I could produce such an error but nothing happend.
-
May 6th, 2004, 03:56 AM
#4
Indeed, I misunderstood your intention of using UDP to find out something about the local interface adapter.
I always use "GetIfTable" where you get all interfaces and their operational state!
But this requires at least Windows 98 or Windows NT4 SP4 or later.
The Saviour of the World is a Penguin and Linus Torvalds is his Prophet.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|