mIRC Homepage
Posted By: Rooster74 Sockets question - 06/02/03 10:14 PM
I had made a script that can ping a half-life based server and report the ping. It uses a udp socket and works fine, but if I accidently enter the wrong port I dont get any responce. Is there a way to read the packet sent back saying that the destination was unreachable? The protocal used for sending the Destination Unreachable packet is ICMP.
Posted By: Hammer Re: Sockets question - 07/02/03 12:17 AM
From the help file:

On error: if a /sockudp fails, it sets $sock().wserr to the error value, and triggers the on sockwrite event with $sockerr set.

ICMP Type 3 is Destination unreachable, which breaks down into 6 other types, based on the code field.
0 = network unreachable;
1 = host unreachable;
2 = protocol unreachable;
3 = port unreachable;
4 = fragmentation needed and "Don't Fragment" set;
5 = source route failed.

So, perhaps Winsock will return these values in $sock($sockname).wserr and $sock($sockname).wsmsg, mapped to Winsock's error values.
Posted By: Rooster74 Re: Sockets question - 09/02/03 05:54 PM
Sorry it took me so long to reply, I was gone for a while.

Ok, in the udpread I have a line that checks if the $sockerr > 0, and returns if it is but im not real sure if its triggering. I took and added an echo at the very beginning just to see if the udpread is even reading anything and it doesnt appears be. Since the udpread does not appear to work for reading the DestUnreach packet, what would I need to use? This is confusing me and I havent be able to find anything online for mirc besides stuff related to flooding a user with ICMP DestUnreach packets, which I do not care about.
Posted By: Hammer Re: Sockets question - 10/02/03 01:19 AM
on *:SOCKWRITE: .. not on *:UDPREAD:
Posted By: Rooster74 Re: Sockets question - 11/02/03 08:16 PM
Thank you very much Hammer . It works perfectly now.
© mIRC Discussion Forums