LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   netcat hostname question (https://www.linuxquestions.org/questions/linux-networking-3/netcat-hostname-question-943377/)

installer69 05-05-2012 03:09 AM

netcat hostname question
 
Hi,
I am using netcat to send some text from a linux tablet to my windows laptop.

All works perfect if I specify the ip address of the laptop.

Is it possible to specify the computer name instead and if so in what format. I have tried ron-PC and WORKGROUP\ron-PC but netcat says 'forward host lookup failed: Unknown host.

Before anyone suggests it, yes I know I can set a static ip address for the laptop but I have a lot of devices on the network that I will need to broadcast to so am trying to avoid setting static ips on them all. And I just want to see if the other way is possible now I have the bit between my teeth.

I'm using a perl script to system call netcat if anyone has any other suggestions like how to see what active computers are on the network, grab their ip addresses, chuck them in a string and use them in netcat (don't ask for much, do I)

If I do end up setting statics and listing them all for netcat can anyone tell me what command flag to use to prevent netcat hanging if one of the computers are off?

Thanks for any input.

jschiwal 05-05-2012 03:28 AM

If you don't use a name server, are you using avahi? If so try ron-PC.local as the hostname.

installer69 05-05-2012 03:46 AM

Thank you so much. I spent a couple of hours searching the net with all possible search terms that might lead me to an answer and despite all that time looking none of the results mentioned avahi. I googled it, read about it and inserted it just as you suggested and it worked. Thank you so much, I can now send caller id to all devices around the house.

Just one last question, will it degrade gracefully if ron-PC (for example) is off or will it hang?

jschiwal 05-05-2012 06:16 AM

It will probably hang for around 5 seconds waiting for a response.

At home, I entered the IP addresses I want assigned to my hosts in my router's IP/MAC clients' table. This way, I can use DHCP on the hosts but still have fixed addresses, and maintain an /etc/hosts file.


All times are GMT -5. The time now is 09:09 PM.