|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Hi,
I`m trying to do some multicast programming, and i`m looking for a C-function to convert an Interfacename to an IP-address or/and a C-function to convert an Interfaceindex to an IP-address. I need it for the mcast_set_if(int sockfd, const char *ifname (!), u_int ifindex(!)) function by STEVENS. Perhaps I'm wrong, but I think the INTERFACENAME is something like eth0 ??!!??!?!? And what is the index, is there kind of table for each system/ computer ??? like: loopback --> 0 eth0 --> 1 and so on. Thanks for the help! ;-) |
| Sponsored Links | ||
|
|
|
||||
|
Even easier than getpeername() is the function gethostname(). It returns the name of the computer that your program is running on. The name can then be used by gethostbyname(), to determine the IP address of your local machine.
#include <unistd.h> int gethostname(char *hostname, size_t size); The arguments are simple: hostname is a pointer to an array of chars that will contain the hostname upon the function's return, and size is the length in bytes of the hostname array. The function returns 0 on successful completion, and -1 on error, setting errno as usual. |
| Sponsored Links |
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C Network Programming - recv() help | Octal | Programming | 2 | 05-12-2007 02:33 AM |
| Network Programming in Unix | powermind | Programming | 2 | 09-02-2006 08:46 AM |
| Network Programming in C | vibhory2j | Programming | 1 | 04-15-2004 01:57 PM |
| Want To Learn Network Programming | hubin330 | Programming | 2 | 12-20-2003 01:04 PM |
| Unix Network Programming | dangral | UNIX for Dummies Questions & Answers | 3 | 12-10-2003 09:30 AM |