I have to open an NSStream to a wifi access point that has only a numerical address, not a name. It takes NSStream 30-40 seconds to open a socket. In experimenting, i found that telnet-ing to the AP from a windows box was instantaneous, but on a mac, connecting the same 30-40 seconds. in researching telnet, i found that the implementation is a little different on a mac, in that it by default tries to to a name lookup. reading the manual page for telnet, i found:
-N Prevents IP address to name lookup when destination host is given as an IP address.
when I used "telnet -N IP-address port", my connection was instantaneous! I suspect that this same problem is causing the delay in my NSStream connection. Is there any way to do the equivalent of setting the"-N" flag in NSStream?
It looks like NSHost is not available on Cocoa Touch, so you cannot force a host with a given address, though I don't know if that negates the need for a dns lookup.
This problem has been around since 2005, though this might not apply to Cocoa Touch libraries. In any case there is no given solution:
http://developer.apple.com/library/ios/#DOCUMENTATION/Networking/Conceptual/CFNetwork/Concepts/Concepts.html#//apple_ref/doc/uid/TP30001132-CH4-SW10
http://developer.apple.com/library/ios/#DOCUMENTATION/CoreFoundation/Reference/CFSocketRef/Reference/reference.html#//apple_ref/doc/c_ref/CFSocketCreate
Related
Is it possible to progamatically change the Preferred DNS servers for an active WIFI IPV4 connection using Delphi 10.3 and Windows 10? There are occasions when it would be useful for my program to use alternative DNS Servers. Normally to change them one has to take the long route of going through Network and Internet Settings and manually adding the preferred DNS Addresses. I was hoping to find an API call that may address this issue and allow me to simply select my chosen DNS Addresses from a combobox or similar and switch between the chosen addresses and those provided by the ISP, but as of yet my internet searches have yielded nothing.
Any Help would be much appreciated.
My internet is only working for heavily cached sites. Reddit, Gmail, Facebook, etc. The odd thing is, sites like Reddit make queries to non-reddit sites to import the images and they pop up fine when viewing from there, but when I get sent to out.reddit.com and then if I go elsewhere to other non-heavily cached sites, I get timed out connection error.
I can't even visit SpeedTest.net because it times out. I also can't even post a question on StackExchange because of it. What could possibly be going on and how to I debug?
EDIT: I had an inclination that it had to do with Docker. I removed all traces using a powershell script and through remove programs and still didn't work.
user3654055 are friends IRL and we debugged this in person.
It's always best to start from layer 1 and work our way up.
user3654055's computer could connect to wireless networks. This tells us layers 1 and 2 are working
.
user3654055's computer received a DHCP lease. Further testing of layer 3 showed inconsistent results with pinging local IP addresses.
I ran route print to print all routes. This produced a huge amount of output.
Normal output for a Windows computer connected to a flat LAN should produce perhaps 3 routes.
user3654055 had recently installed Docker and attempted to set up a private
internal network for the containers on their PC.
user3654055 had created two virtual networks (one internal vEthernet switch, one external vEthernet switch), a NAT interface, and bridged the wireless adapter to one of those interfaces and had not set up routing correctly for any traffic.
This produced the above scenario where certain traffic was routed correctly or hit the cache and the page would load, but most traffic was routed incorrectly and resulted in a timeout.
Disabling all the vEthernet switches and the NAT interface and removing the wireless adapter from the bridge let the user use their wireless card again.
The above configuration could work if the user set up routing correctly by hand, but we can save that for a later date.
Sounds like a DNS issue...do you know what you are using as a DNS address? You could try using Google's which is 8.8.8.8 for primary and 8.8.4.4 for secondary. Failing that does it get better following a router reboot?
To debug your internet connection, I would at first check what happens with tracert.
Traceroute command shows you the path taken by your packets and its latency from hop to hop.
From console (linux) or from cmd (windows)
tracert stackoverflow.com
this shows you where you are lagging, the first entry may be your router IP. If the first entry appears with high latency try to reboot your router.
Checking for DNS Issues
Try to use nslookup. This is what you should get:
nslookup stackoverflow.com
Server: UnKnown
Address: 192.168.1.1
Risposta da un server non autorevole: //italian comment
Nome: stackoverflow.com.home
Address: 54.72.52.58
if this fails or replies with high latency try to change your DNS to Google DNS.
Primary DNS: 8.8.8.8
Secondary DNS: 8.8.4.4
On a local network I'm sending a WOL (Wake-On-LAN) packet using sendto to the target MAC address. The code for that works without any problems and the target machine is turned on correctly. The problem is, that I don't know if the target machine has a LAN cable attached or not. If it's not attached, then the whole process fails. Unfortunately, sendto is unidirectional, so I don't know if my magic packet arrived.
I'm wondering about the best and fastest way to find out if WOL succeeded or not. Waiting for the device to boot up completely so I find out get and ping its IP address takes way too long.
Is there a way to "ping" a MAC address, i.e. get some sort of Layer-2-reply?
I need this solution for a Delphi application, but if you have a solution for a different language at hand you're welcome to post that as well. Thank you!
My app tries to determine the IP of a web server located on the same LAN when it starts up.
It works out the IP range to scan, and uses NSURLConnection objects with a 1 second time out to determine whether an IP is reachable, and if it is, try to call a service on it, if the service call is successful then we know we've found the correct IP.
The problem though is that the app cannot open more than 5 connections at a time, even though all the connections have different IPs to connect to. I would get about a dozen connections firing off but the rest will just report The request timed out. without ever leaving the device.
I have read that this restriction applies to NSURLConnection connections to a single IP address, but as I said, each connection has its own different IP.
I have also tried using the SCNetworkReachability to determine whether an IP is reachable but all it tells me is that the IP addresses on the LAN are reachable, in theory, without making an actual connection.
Are there reliable ways to connect to more IPs at a time?
Every operating system maintains a maximum number of sockets per process. I couldn't find an authoritative source for iOS, but it would make sense for Apple to keep that number very low and five seems to be a common answer by others trying this.
You may want to look at NSOperationQueue to manage the connections (see Asynchronous HTTP Client Using NSOperationQueue) or use AFNetworking to do all the real work.
I've searched this subject in stackoverflow and found out that a telnet library would help, and I found a telnet lib here: C# Telnet Library
but I don't know how I can use a telnet library to open a port in my router. I'm using an AT&T 2wire router. Any hints on how I can do this?
You can't. The 2wire router is an island unto itself, if it decides to block a port nothing external can (or should) be able to change that. You are on the wrong track, and would need to restate your goals in order to get a useful answer.
UPnP and other "Hole Punching" techniques do exist: but you'll be in a world of hurt if you try to reply on them for any widespread deployment.
Perhaps you meant to open a connection to a remote server and then establish two way communication. That is easy... and how other games and tools get the job done.
Technically speaking you should not be able to. You shouldn't have outside programatic access to a router to open a port if it's blocked.
If what you mean is opening a port for communication (that is not blocked) then you can simply create Sockets with the address and port (ex. localhost 7777) to establish inter process communication or simply communication with another server.
As I mentioned in a comment below there are ports that are available for use (in C# this can be easily tested, a quick google search will find you many snippets of code for testing if a port is open). A simple approach is to simply start at port 1024 (I believe this is the correct lower bound for ports that should be used by applications, someone correct me if I'm wrong) and just start counting up until you find a port that is available, if you find you've reached some upper limit you can simply report that a connection cannot be made. I hope this clears up a little more and if I have time I will try to find some code I have for this and edit it in but honestly a quick search can net you similar code for checking ports in C#.