Welcome to Soft32 Linux Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

gethostbyaddr() to resolve windows hostname

 
   Soft32 Home -> Linux -> App Development RSS
Next:  syslog problem  
Author Message
allug4me

External


Since: Sep 01, 2007
Posts: 2



(Msg. 1) Posted: Sat Sep 01, 2007 7:11 am
Post subject: gethostbyaddr() to resolve windows hostname
Archived from groups: comp>os>linux>development>apps (more info?)

Hi,

I am writing a small echo client in C on GNU/Linux system. The echo
server is on Windows System. I am trying to use gethostbyname to
resolve the Windows Hostname.
But I am not able to do so.

The name is not being resolved. I am able to use my application only
with IP Address.

Let me explain my environment:

Router-----------windows(echo server)
|
|
|
Linux(echo client)


Both windows and linux systems have obtained ip address via dhcp from
the Router.

my echo client is running on linux system.

i am able to use ip address. but my concern is i need to use the
hostname as it is dhcp enabled and the ip address keeps on changing.

the router shows the windows hostname - ip address mapping.

windows-pc 192.168.10.100

but when i try to use gethostbyname() with the "windows-pc" as the
argument for hostname, it can't resolve to the ip address.


am i missing something?
Is there any different function that i should use?


Also the windows pc is in a workgroup named "HARDWARE".

One more point is that I am able to run the "scp" command on my linux
system to access the windows pc

#scp windows-pc

The point i am trying to make is that scp is able to resolve the
windows-pc name into an ip address but my program can't. so i suspect
is there any different function call.

please provide me suggestions.

Thanks

Best Regards,
allug
Back to top
Login to vote
Juha Laiho

External


Since: Jul 28, 2003
Posts: 5



(Msg. 2) Posted: Sun Sep 02, 2007 1:07 am
Post subject: Re: gethostbyaddr() to resolve windows hostname [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

allug4me DeleteThis @gmail.com said:
>I am writing a small echo client in C on GNU/Linux system. The echo
>server is on Windows System. I am trying to use gethostbyname to
>resolve the Windows Hostname.
>But I am not able to do so.
>
>The name is not being resolved. I am able to use my application only
>with IP Address.
>
>Let me explain my environment:
>
>Router-----------windows(echo server)
>|
>|
>|
>Linux(echo client)
>
>
>Both windows and linux systems have obtained ip address via dhcp from
>the Router.

.... ok, and you want host names. For that, you should have DNS server
running (and actually a dynamic DNS, updated by your routers DHCP
server when it hands out addresses).

I don't think ADSL routers generally provide this kind of functionality.

What might work would be to configure your router to assign fixed
addresses for clients, and place the address-name relationships on
/etc/hosts on the Linux machine (unless you want to run a full-blown
DNS server there).
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
Back to top
Login to vote
Display posts from previous:   
Related Topics:
How can i register a link protocol for browsers - I want to add an action to the system so that every time a user clicks in a link with for example ..

storing the data in ln2440 target board memory - hai.. i using the target board ln2440sbc..and linux OS.. (16Mb flash and 32Mb sdram) i have cross compiled and porte...

GTK run error - hi i had created one same application in glad interface designer with c option.the n i compiled the same after that i....

C++ -> mplayer, stdin, stdout, popen / fork / pipe... - Hello everybody. I tried to work this out on my own for about 6 hours non-stop now and I just don't get it working.......

[Samba] how do I resolve local machine names for a windows.. - I am having problem resolving local machine names from the workstaions, but I can resolve them from the server e.g. I...

[Samba] unable to ping windows hosts by hostname - Hello, On RedHat 9 with samba-2.2.7a-7.9.0, I am connecting to a windows network through a cisco VPN connection. When...
       Soft32 Home -> Linux -> App Development All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 Windows
  Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]