Go Back   The UNIX and Linux Forums > Top Forums > Programming
.
google site



Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-16-2002
Registered User
 

Join Date: May 2002
Location: Germany
Posts: 5
Question Network programming

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
  #2 (permalink)  
Old 05-18-2002
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 326
Re: Network programming

Hi,

I have some hint for you. You have a C function called the gethostbyname and gethostbyaddr. I think this should solve your problem. else you can also try "resolver", but i guess "resolver" is linux specific.

regards
penguin
  #3 (permalink)  
Old 05-21-2002
killerserv's Avatar
Unix Predator
 

Join Date: Dec 2000
Location: Phoenix, AZ
Posts: 670
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0