Re: loopback traffic gets to cable modem <SOLVED>
Re: loopback traffic gets to cable modem <SOLVED>
- Subject: Re: loopback traffic gets to cable modem <SOLVED>
- From: Jeffrey Johnson <email@hidden>
- Date: Wed, 20 Nov 2002 08:22:52 -0500
>
On Friday, October 25, 2002, at 07:51 AM, I wrote:
>
>
> We're in the process of doing beta testing for our app (>=10.2
>
> only), and we're getting reports from users directly connected to
>
> cable modems that their activity lights are "going crazy" when our
>
> app is running.
>
>
>
> We have a daemon server process with the following code cribbed out
>
> of Stevens (hacked up a bit for posting):
>
>
>
> char host[] = "127.0.0.1";
>
> char serv[]= "5555";
<snip>
>
>
>
> if ( (n = getaddrinfo(host, serv, &hints, &res)) != 0)
>
> err_quit("tcp_listen error for %s, %s: %s", host, serv,
>
> gai_strerror(n));
<snip>
>
> The clients connect with the following (where host is "127.0.0.1", port
>
> is "5555"):
>
>
>
> static int tcp_connect_recover(const char *host, const char *serv,
>
> char *errString)
<snip>
>
> if ( (n = getaddrinfo(host, serv, &hints, &res)) != 0) {
>
> sprintf(errString,"tcp_connect error for %s, %s: %s",
>
> host, serv, gai_strerror(n));
>
> return(0);
>
> }
>
> ressave = res;
<snip>
>
> We're using the loopback interface with the following assumptions:
>
> 2) The network stack
>
> should be smart enough to see that traffic from the client(s) to the
>
> server is using the loopback address and not propagate the bits onto
>
> the external network.
Well, it appears that the transaction traffic was not being exposed to the
LAN, but getaddrinfo(), bless its little heart, goes out for a DNS lookup even
if the hostname string is already in octet/dot notation (I was just using it
to fill in a valid addrinfo struct).
Dunno what it comes back with, but it makes the trip anyway. Wouldn't it be a
reasonable optimization for getaddrinfo() not to do a lookup in this case?
Since we make a new connection for every transaction (don't ask) something
was blinking the traffic LED for each connection (it's kinda hard to get users
to set up a sniffer :-)). Once we created a static sockaddr buffer with the
correct loopback values, the user's traffic LED quit blinking (and the
transaction speed went way up, too).
Hope this helps someone in the archives....
Thanks
Jeffrey Johnson
Macintosh Development
Wavefunction, Inc.
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.