mIRC Homepage
Hi all,

I have just noticed that my sockets are taking ages to open. I then realised it is only since I downloaded the new version. I have used this code on mIRC 6.35 and on mIRC 7.1 and got two vastly different results.

Code:
alias test_socket {
  set -e %socket_time $ticks
  sockopen test_socket www.google.com 80 
}
on *:sockopen:test_socket:{ 
  echo $color(info) -a It took  $calc(($ticks - %socket_time) / 1000) seconds for $sockname to open.
  unset %socket_time 
  sockclose $sockname
}


mIRC 7.1 returned It took 15.031 seconds for test_socket to open.

mIRC 6.35 returned It took 0.078 seconds for test_socket to open.

I find it very troubling, and wonder what the problem could be.
Can you identify whether the connection is successful or not? What error (if any) is reported if you use this code?

Code:
alias test_socket {
  set -e %socket_time $ticks
  sockopen test_socket www.google.com 80 
}
on *:sockopen:test_socket:{
  echo -a Time: $calc(($ticks - %socket_time) / 1000) seconds
  unset %socket_time 
  if ($sockerr > 0) {
    echo -a Connection failed: $sockerr / $sock($sockname).wsmsg
    return
  }
  echo -a Connection successful
  sockclose $sockname
}
Can't reproduce it here.
7.1 is slower, but not noticable.

Do you have the UPnP settings enabled?

mIRC 7.1:
It took 0.063 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.078 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.063 seconds for test_socket to open.
It took 0.078 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.078 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.078 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.078 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.

mIRC 6.35:
It took 0.032 seconds for test_socket to open.
It took 0.047 seconds for test_socket to open.
It took 0.046 seconds for test_socket to open.
It took 0.032 seconds for test_socket to open.
It took 0.046 seconds for test_socket to open.
It took 0.047 seconds for test_socket to open.
It took 0.031 seconds for test_socket to open.
It took 0.031 seconds for test_socket to open.
It took 0.047 seconds for test_socket to open.
It took 0.031 seconds for test_socket to open.
It took 0.031 seconds for test_socket to open.
It took 0.031 seconds for test_socket to open.
Can't reproduce this either with OP code, it makes sense to me that the connexion is successful since it get a result
Originally Posted By: Wims
Can't reproduce this either with OP code, it makes sense to me that the connexion is successful since it get a result


The ON SOCKOPEN event will be triggered even if the connection fails. You must check $sockerr to find out.
Oops, that's true.
I can confirm that the socket does open successfully.

mIRC 7.1 Returns

Time: 15.047 seconds
Connection successful

mIRC 6.35 Returns

Time: 0.031 seconds
Connection successful



You didn't mention if you have upnp enabled. That is most likely the cause.
I have not been able to reproduce this so far. The connection is immediate in my tests. Which version of Windows are you using?

UPnP is unlikely to be the cause of any issues since UPnP is only used when mIRC needs to listen for an incoming connection not when opening an outgoing connection. However you can try disabling UPnP in the Options/Connect/Options/Ports dialog to see if that helps.

Also in the Ports dialog, if you disable the Port Range options, does that help?
Hi,

Sorry for taking so long to reply.

I am using Windows XP Pro

I went to options/ports in 7.1 and could not find how to disable the range. I have enclosed a screenshot below, unless you want me to clear both boxes? not sure what you meant.

Also disabling uPNP had no effect!

Even if it is upnp why is mIRC6.35 not affected?

Many thanks.

http://img412.imageshack.us/img412/5692/mircscreenshot.jpg

version 6.35 has no upnp support, that is why we were talking about it.
Yes, if you could uncheck all boxes in the "Port Range" section and then let us know if that helps.
Hi there,

Just did that and still get the same problem.

Time: 15.063 seconds
Connection successful

Regards,
Have you tried disabling any anti-virus or firewall software that may be hampering mIRC in the name of security?

It could be you've added mIRC 6.35 to a whitelist previously.
Hi starbucks,

I disabled windows firewall, and my AV, still the same result. I did the same with my routers firewall etc.

Take in mind mIRC 6.35 opens sockets instantly.

If it helps to debug I am happy for you to connect to my machine.

-

Time: 15.047 seconds
Connection successful

Its always seems to be round the 15 second mark for some reason.

Maybe it's an option to use a network analyzer like Wireshark, to see what the difference in behaviour is between 6.35 & 7.1.
I also noticed this with my HTTP-Check script (checks an URL and tells me the title, or whether it redirects to a potentially dangerous site).

6.35 was pretty quick, 7.1 takes considerably longer. I also noticed this with /dns queries, so I think it might be related to that (remember that IPv6 is now available from within mIRC).

UPnP is disabled, all ports in the configuration are unchecked, and I don't have a firewall that could affect this.
Originally Posted By: BhaaL
I also noticed this with my HTTP-Check script (checks an URL and tells me the title, or whether it redirects to a potentially dangerous site).

6.35 was pretty quick, 7.1 takes considerably longer. I also noticed this with /dns queries, so I think it might be related to that (remember that IPv6 is now available from within mIRC).

UPnP is disabled, all ports in the configuration are unchecked, and I don't have a firewall that could affect this.


Could you tell us the result when you execute the following code, both in 6.35 and in 7.1

Code:
alias test_socket {
  set -e %socket_time $ticks
  sockopen test_socket www.google.com 80 
}
on *:sockopen:test_socket:{
  echo -a Time: $calc(($ticks - %socket_time) / 1000) seconds
  unset %socket_time 
  if ($sockerr > 0) {
    echo -a Connection failed: $sockerr / $sock($sockname).wsmsg
    return
  }
  echo -a Connection successful
  sockclose $sockname
}


Usage /test_socket
Code:
Time: 0.172 seconds
Connection successful


I did some testing with /dns using the same piece of code (except /dns instead of /sockopen, and on DNS instead of on SOCKOPEN). The first request for a domain takes 10+ seconds, the following ones are quick (cached?)
I guess its the same thing when doing /sockopen domain.tld instead, since someone needs to resolve the IP first.
Originally Posted By: BhaaL
I guess its the same thing when doing /sockopen domain.tld instead, since someone needs to resolve the IP first.
Which obviously means his tests should be as fast as in 6.35 when he uses one of the IPs of www.google.com
We'll see...
Originally Posted By: BhaaL
Code:
Time: 0.172 seconds
Connection successful


I did some testing with /dns using the same piece of code (except /dns instead of /sockopen, and on DNS instead of on SOCKOPEN). The first request for a domain takes 10+ seconds, the following ones are quick (cached?)
I guess its the same thing when doing /sockopen domain.tld instead, since someone needs to resolve the IP first.


Was this done in 7.1 or 6.35?
The new version of mIRC asks Windows to return both IPv4 and IPv6 addresses for a domain name. It could be that for some users resolving IPv6 is slower than for other users for some reason. It is possible that the delay could be due to an ISPs name servers or your Windows configuration. I will change the DNS lookup in the next version so that it only asks for IPv6 if you have explicitly requested it by using/enabling features that need it.
Originally Posted By: HaleyJ
Was this done in 7.1 or 6.35?

7.1

Khaled: I'm on Windows 7, but I don't have any IPv6-capable interfaces other than loopback; the rest only gets IPv4. And I'd say it will still take some time until my ISP offers IPv6.
Making the request more explicit is IMO a good idea - just like the old one used to be and the new one has its switches for:
IPv4: /dns domain.tld or /dns -4 domain.tld
IPv6: /dns -6 domain.tld
both: /dns -46 domain.tld
My ideas about this problem:

Other apps can do IPv4/IPv6 resolution correctly, without such delays, and without the explicit need to enable IPv6. So it Can Be Done. This is the given, which we have to work with. So what's wrong? How do we fix it properly?

A likely cause of the problem is broken home NAT boxes which don't respond to AAAA queries at all, then mIRC times out after 15 seconds or so.

The recommended way to do DNS resolution is to use getaddrinfo(), the standard API lookup. I checked that this lookup, whereever i tried (both linux and windows), completely omits the AAAA lookup, if the PC has no IPv6 connectivity. This is done, explicitly, as a workaround for such broken NAT routers. If using getaddrinfo is impossible, then omit the AAAA lookup if IPv6 connectivity lacks. To know if you have IPv6 connectivity, look for the presence of global scope IPv6 addresses.

edit: i remember/read elsewhere that you do use getaddrinfo(), but you manually resolve v4 and v6 on their own. first, i advise against this, because the OS is designed to do this properly, taking care of all the edge cases, to make ipv6 work *without problems*. you're misusing the API. secondly, because you manually do v4 and v6 lookups independently, the above applies.
Thanks for the comments, however mIRC resolves IPv4 and IPv6 separately because testing showed that the API is broken and behaves differently under different versions of Windows. I think I may have mentioned that in a previous post. In any case, as I indicated in my above reply, this issue has been resolved for the next version.
resolved by explicitly requiring one to state that it's ipv6 with a -6 flag? do you intend this to be the long term solution?

in another thread you said you had difficulty with the idea of checking for ipv6 connectivity, saying you'd have to connect to some internet server for it. can you comment on the idea of looking for the presence of global scope ipv6 addresses? i can test things on XP and vista (and linux) if it helps.
This was resolved by making sure that mIRC only resolves IPv6 connections when necessary, eg. if mIRC is binding to an IPv6 address, or if IPv6 support has been enabled in the ports dialog, or if you are using the -6 switches, and so on. As far as I am aware, this covers all of the situations where IPv6 can be used. If I have missed one, or if it is not working for you, please let me know.
© mIRC Discussion Forums