I'm keeping to the 2.2 Linux kernel right now until I can suitably deal with the problems with poll() in a 2.4 kernel. However, I've discovered something else. When a UDP Socket does a sendto of a non-existent domain or non-open port the next recvfrom() call (or poll()) returns with an error!
Unfortunately I couldn't find anything in Socket or UDPSocket that gets these errors or even clears them. (I could be horribly mistaken here, if so please correct me if they exist.)
I would like to ask for another function to be added to Socket, just for this sake, something like Socket::getLastError() that, at this point, does nothing but clear the last error by either calling getsockopt( ..., SO_ERROR, ...); or tries to use recvmsg() to get the error, both I've discovered clear the error, though for some reason neither one works properly for me, they both return an error status (-1) and perror() receives "recvmsg: Resource temporarily unavailable" and "getsockopt: Bad address."
I find myself afraid to ask if perror() is threadsafe. Then I thought to myself that on a UDP Socket it was silly to worry about anything *but* a fatal error (which would stop the program I think) because UDP usually have no error handling in the first place, it's partially the point of the protocol.
If *anyone* can help me on this issue, I'm game, I'd really love to be able to get that error back, but seeing as how I've spent hours trying to figure out how to do it (or how other programs do it) and I've come up with naught I'm just adding that function I suggested to my copy of the CommonC++ Library until one of the developers puts something similar in or allows me to submit a patch that'll add it.
Amerist.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've figured out how to use recvmsg properly; my own dumb fault for thinking that I can skim manpages. Anyway, the reason why recvmsg was returning "Resource temporarily unavailable" was because I wasn't setting the IP_RECVERR option on the socket! Once I'd discovered that I had to turn that on it started receiving the error ( the ICMP "Connexion Refused" error ) and I'm right now working on code that can parse it meaning that I can write a real UDPSocket::(or Socket::)getLastError() function.
Amerist.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hails!
I'm keeping to the 2.2 Linux kernel right now until I can suitably deal with the problems with poll() in a 2.4 kernel. However, I've discovered something else. When a UDP Socket does a sendto of a non-existent domain or non-open port the next recvfrom() call (or poll()) returns with an error!
Unfortunately I couldn't find anything in Socket or UDPSocket that gets these errors or even clears them. (I could be horribly mistaken here, if so please correct me if they exist.)
I would like to ask for another function to be added to Socket, just for this sake, something like Socket::getLastError() that, at this point, does nothing but clear the last error by either calling getsockopt( ..., SO_ERROR, ...); or tries to use recvmsg() to get the error, both I've discovered clear the error, though for some reason neither one works properly for me, they both return an error status (-1) and perror() receives "recvmsg: Resource temporarily unavailable" and "getsockopt: Bad address."
I find myself afraid to ask if perror() is threadsafe. Then I thought to myself that on a UDP Socket it was silly to worry about anything *but* a fatal error (which would stop the program I think) because UDP usually have no error handling in the first place, it's partially the point of the protocol.
If *anyone* can help me on this issue, I'm game, I'd really love to be able to get that error back, but seeing as how I've spent hours trying to figure out how to do it (or how other programs do it) and I've come up with naught I'm just adding that function I suggested to my copy of the CommonC++ Library until one of the developers puts something similar in or allows me to submit a patch that'll add it.
Amerist.
ReHails,
Okay, belay some of that last post.
I've figured out how to use recvmsg properly; my own dumb fault for thinking that I can skim manpages. Anyway, the reason why recvmsg was returning "Resource temporarily unavailable" was because I wasn't setting the IP_RECVERR option on the socket! Once I'd discovered that I had to turn that on it started receiving the error ( the ICMP "Connexion Refused" error ) and I'm right now working on code that can parse it meaning that I can write a real UDPSocket::(or Socket::)getLastError() function.
Amerist.