You are not logged in.
Pages: 1
Depends on what exactly you mean with "active" and what kind of socket
we're talking about. UDP is never active or inactive as such, because there
is no connection. For TCP there is a connection, but if one host silently dies
it can take a long time for the other to discover that it's gone. The only way
to know for sure that a socket is active is to actually use it and receive data.
If a TCP connection gets broken and keep-alive is disabled, you will never
notice until you try to send something and the TCP stack gives up trying to
deliver the data, which can take a very long time. But normally when there is
no hardware crash or NAT routers silently forgetting about your connection,
you will receive an error notification when you try to send or receive.
Offline
I still don't know what you mean by that... First of all, it's rather hard to have a plain IP socket, without TCP or UDP being involved as well... Are you talking about an AF_INET/SOCK_RAW socket or something?
And, I still don't know what you mean by "active", exactly... Do you just mean is it still usable? If so, the only case it wouldn't be is the case we previously mentioned, where it's a TCP socket and the connection went dead... Like we said, in that case, you'd want to use keepalive probes to be able to detect such otherwise silent connection deaths...
Offline
Well, then, like i3839 said, there are no connections involved in UDP, so I have no idea what "active" would even mean in regards to a UDP socket... As long as you haven't closed it, you should be able to use the UDP socket at any time...
Offline
In case you want to know that the socket is still alive as a file descriptor
and not closed or something else than your UDP socket, you could call
getsockname() on it to check. But normally you would make sure that
you always know if a socket is still open or not, and remove all references
to it when some part of the code does close it.
The kernel will never close the fd behind your back, it will only close it
when you ask it to, or when the process exits.
Offline
In java there is a function for checking wheather the socket is active or not..
I thought I would make a comic that hopefully helps...
Over Simplified TCP Socket Under Simplifed UDP Socket
Connection Does Not Connect
Person Let me know when Person
you're wet-v Can't
Connection Connect
I am Pouring ^ v Doesn't annouce
Water~ ^ v Pours Water~
\ ^ v \
| ^ v |
v ^ v |
Funnel \ / ^ v Funnel \ | /
\ / ^ v \ | /
\ / ^ v \|/
| | ^ v |||
^ v |
Timer Bucket |~~~~~| ^ v |
When Full Tip |_____| ^ v |
_____ ^ v ~~~v~~~
When Wet wake / \ ^ v ~/ \~
up and say I'm | 0 0 | ^ v ~ | _ _ | ~
wet... \ ^ / ^ v ~ \ ^ / ~
> \_o_/ ^ v ~ \_*_/ ~
^ | ^ v ~ ~
^ v ^ v ~ ~
^ Responds ^ v ~ ~
^ with... ^ v ~ ~
^ Nothing ^ v ~ ~
^ Yet ->>>>>^ v ~ water ~
^ v ~~~~~~~~~~~~~
^<<<<<<<<<<<<<<<v ~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~
In a TCP senario TCP, wait's and it In a UDP senario, the software
also responsds based on timing logic. you write needs to respond, not UDP
DougPan
Now that's the best explanation I've ever heard... I mean seen.
Jerry
Indeed... New non-spammer users are a rare treat these days... Hell, I'd even welcome the typical old post we used to get from new school students wanting us to do their homework for them! (I'd still just ridicule them and make them do it themselves, of course, but any non-spam content would be a nice change of pace these days...)
Offline
I think i3839 just meant that the forum is dying (or is already the walking dead)... We used to be a lot more active in the past, but in recent years we hardly get any real programming discussion anymore...
Offline
Yeah, what Rob said. It's not just this forum, but forums in general seem to be a getting quieter. At least my impression is that the new generation doesn't do forums.
I would like to know if you receive any spam via your subscription. I never did, but maybe they're smart enough to exclude admins. All those dormant bot accounst must be there for some reason... I disabled user PMing for this reason.
I miss those interesting problem questions, I loved debugging them. :-/
Offline
I thought I would make a comic that hopefully helps...
Over Simplified TCP Socket Under Simplifed UDP Socket
Connection Does Not Connect
Person Let me know when Person
you're wet-v Can't
Connection Connect
I am Pouring ^ v Doesn't annouce
Water~ ^ v Pours Water~
\ ^ v \
| ^ v |
v ^ v |
Funnel \ / ^ v Funnel \ | /
\ / ^ v \ | /
\ / ^ v \|/
| | ^ v |||
^ v |
Timer Bucket |~~~~~| ^ v |
When Full Tip |_____| ^ v |
_____ ^ v ~~~v~~~
When Wet wake / \ ^ v ~/ \~
up and say I'm | 0 0 | ^ v ~ | _ _ | ~
wet... \ ^ / ^ v ~ \ ^ / ~
> \_o_/ ^ v ~ \_*_/ ~
^ | ^ v ~ ~
^ v ^ v ~ ~
^ Responds ^ v ~ ~
^ with... ^ v ~ ~
^ Nothing ^ v ~ ~
^ Yet ->>>>>^ v ~ water ~
^ v ~~~~~~~~~~~~~
^<<<<<<<<<<<<<<<v ~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~
In a TCP senario TCP, wait's and it In a UDP senario, the software
also responsds based on timing logic. you write needs to respond, not UDP
DougPan [url=http://gold.com/]stripped[/url]
Last edited by Lagger (2017-04-13 11:27 AM)
Offline
Pages: 1