Re: loopback traffic gets to cable modem?
Re: loopback traffic gets to cable modem?
- Subject: Re: loopback traffic gets to cable modem?
- From: Vincent Lubet <email@hidden>
- Date: Fri, 25 Oct 2002 09:04:23 -0700
Jeffrey,
I've compiled and build your code and failed to reproduce the problem.
It would be interesting to get the detailed configuration of your
users' systems, for example:
- Do they use PPPoE?
- What are the addresses?
- What is the DNS server addresses?
- What are the DNS search domain?
- What is the hostname?
Vincent
On Friday, October 25, 2002, at 07:51 AM, Jeffrey Johnson wrote:
Hello,
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";
const int on = 1;
struct addrinfo hints, res;
bzero(&hints, sizeof(struct addrinfo));
hints.ai_flags = AI_PASSIVE;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if ( (n = getaddrinfo(host, serv, &hints, &res)) != 0)
err_quit("tcp_listen error for %s, %s: %s", host, serv,
gai_strerror(n));
listenfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
Setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
bind(listenfd, res->ai_addr, res->ai_addrlen);
if (res == NULL) /* errno from final socket() or bind() */
err_sys("tcp_listen error for %s, %s", host, serv);
Listen(listenfd, LISTENQ);
The clients connect with the following (where host is loopback, port
is 5555):
static int tcp_connect_recover(const char *host, const char *serv,
char *
errString)
{
int sockfd, n;
struct addrinfo hints, *res, *ressave;
bzero(&hints, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
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;
do {
sockfd = socket(res->ai_family, res->ai_socktype,
res->ai_protocol);
if (sockfd < 0)
continue; /* ignore this one */
if (connect(sockfd, res->ai_addr, res->ai_addrlen) == 0)
break; /* success */
close(sockfd); /* ignore this one */
} while ( (res = res->ai_next) != NULL);
if (res == NULL) { /* errno set from final connect() */
sprintf(errString,"tcp_connect error for %s, %s", host, serv);
sockfd = 0;
}
freeaddrinfo(ressave);
return(sockfd);
}
We're using the loopback interface with the following assumptions:
1) by using loopback, outside machines won't be able to connect to the
server
process and harass it/hack it.
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.
It looks like assumption 2 may be incorrect. Can someone confirm that
loopback
traffic does or does not get passed to the LAN? We thought this design
would
let us change the addressing later and open the server to external
connections, but not "clutter up" the LAN with traffic in the
meantime. Any
suggestions?
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.