|
|
|
A net IP retrieval
|
|||
|---|---|---|---|
|
#18+
Hi, Sorry for using English, but it's much faster (for me) . :) I've written a Java application that runs on a Linux machine and communicates (via UDP) with the local (to its net) and remote (other nets) hosts. A text file had to be created to contain these nets IPs for broadcasting(locally)/multicasting(remotely). As well some services were added, to access these IPs. ~zeev/nets.txt -------- my_net 190.12.144 remote_net 222.12.150 ... I would prefer to use the same method that I'm using in C/C++, i.e '/etc/networks' configuration file and the 'getnetbyname()' service to retrieve the requested net's IP (instead of the method I've implemented in Java). /etc/networks ------------- 127 my_net 190.12.144 remote_net 222.12.150 ... The problem is that I couldn't find the 'getnetbyname()' service under any Java package. Is there a way to perform it properly ? Sincerely Zeev ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 07.07.2007, 14:50:21 |
|
||
|
A net IP retrieval
|
|||
|---|---|---|---|
|
#18+
Thanks for the response. But the java.net.InetAddress class handles only the '/etc/hosts' file - all the methods retrieve only the host oriented attributes: hostIp by name, hostName by IP, ... etc. There are verification methods, such as isAnyLocalAddress(), isMulticastAddress(), ..., but the provided services are dealing with the already retrieved IP address. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 09.07.2007, 23:13:42 |
|
||
|
A net IP retrieval
|
|||
|---|---|---|---|
|
#18+
Тогда давай описание сабрутины "getnetbyname". С примерами. Или ссылку на документацию. ЗЫ. и забудь о конфигах *никсов. винда тоже ось. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.07.2007, 11:51:34 |
|
||
|
A net IP retrieval
|
|||
|---|---|---|---|
|
#18+
http://linux.die.net/man/3/getnetbyname авторgetnetbyname(3) - Linux man page NAME getnetent, getnetbyname, getnetbyaddr, setnetent, endnetent - get network entry SYNOPSIS #include <netdb.h> struct netent *getnetent(void); struct netent *getnetbyname(const char *name); struct netent *getnetbyaddr(long net, int type); void setnetent(int stayopen); void endnetent(void); DESCRIPTION The getnetent() function reads the next line from the file /etc/networks and returns a structure netent containing the broken out fields from the line. The /etc/networks file is opened if necessary. The getnetbyname() function returns a netent structure for the line from /etc/networks that matches the network name. The getnetbyaddr() function returns a netent structure for the line that matches the network number net of type type. The setnetent() function opens and rewinds the /etc/networks file. If stayopen is true (1), then the file will not be closed between calls to getnetbyname() and getnetbyaddr(). The endnetent() function closes /etc/networks. The netent structure is defined in <netdb.h> as follows: struct netent { char *n_name; /* official network name */ char **n_aliases; /* alias list */ int n_addrtype; /* net address type */ unsigned long int n_net; /* network number */ } The members of the netent structure are: n_name The official name of the network. n_aliases A zero terminated list of alternative names for the network. n_addrtype The type of the network number; always AF_INET. n_net The network number in host byte order. RETURN VALUE The getnetent(), getnetbyname() and getnetbyaddr() functions return the netent structure, or a NULL pointer if an error occurs or the end of the file is reached. FILES /etc/networks networks database file CONFORMING TO 4.3BSD, POSIX.1-2001. SEE ALSO getprotoent(3), getservent(3), networks(5) RFC 1101 REFERENCED BY ipsec_atoaddr(3), ipsec_ttoaddr(3) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.07.2007, 22:46:22 |
|
||
|
|

start [/forum/topic.php?fid=59&msg=34648943&tid=2145203]: |
0ms |
get settings: |
15ms |
get forum list: |
14ms |
check forum access: |
5ms |
check topic access: |
5ms |
track hit: |
51ms |
get topic data: |
12ms |
get forum data: |
4ms |
get page messages: |
59ms |
get tp. blocked users: |
2ms |
| others: | 307ms |
| total: | 474ms |

| 0 / 0 |
