Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!caip!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.unix-wizards Subject: Re: Mildly exotic socket related system call problem - anyone help? Message-ID: <1701@umcp-cs.UUCP> Date: Mon, 26-May-86 03:31:12 EDT Article-I.D.: umcp-cs.1701 Posted: Mon May 26 03:31:12 1986 Date-Received: Tue, 27-May-86 07:37:15 EDT References: <189@comp.lancs.ac.uk> Reply-To: chris@maryland.UUCP (Chris Torek) Organization: University of Maryland, Dept. of Computer Sci. Lines: 46 In article <189@comp.lancs.ac.uk> david@comp.lancs.ac.uk (David Coffield) writes: >... I need to get a machine address from the user e.g. "150.0.0.11" >(in that format, as a string) and compare the network number of that >address with the network number of the address of the machine on >which the program is executing. I would suggest using `inet_addr()' and then `inet_netof()', but: >Now about a year ago I discovered that "inet_addr" caused core dumps >every time you called it ... I presume you have declared them and used them like so: u_long inet_addr(); int inet_netof(); /* assumes int holds >= 24 bits, but... */ int net; struct in_addr t; t.s_addr = inet_addr(string); net = inet_netof(t); >So, questions as follows: >1. Can anyone suggest a way round this problem? Well, you can simply run atoi() on the first number to discover whether the network is class A (< 128), B (128 to 191), or C (>= 192). If B, you need the next number; if C, the next two. You then have the network. Apply the same procedure to the local address, and compare the strings. >2. Does 4.3 have fixed "inet*" routines?? Yes. >3. If so can anyone mail me a copy of working ones??? Hrum. >4. Was 3. an illegal question???? Probably. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu