Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

How to make a WINS query using IO::Socket?

by Kickstart (Pilgrim)
on Jun 18, 2002 at 23:19 UTC ( [id://175532]=perlquestion: print w/replies, xml ) Need Help??

Kickstart has asked for the wisdom of the Perl Monks concerning the following question:

I'm failing to understand some of what the IO::Socket modules does (and maybe what it is capable of). I would like to (on a linux machine) make a WINS query to another machine on port 137. Once I send a request, how does the client making the request retrieve the information?

As well, if anyone knows what form a WINS request would take (not really a Perl question), I would be appreciative.

Thanks!

Edit by dws for more descriptive title

  • Comment on How to make a WINS query using IO::Socket?

Replies are listed 'Best First'.
Re: How to make a WINS query using IO::Socket?
by marcos (Scribe) on Jun 19, 2002 at 07:27 UTC
    I don't know anything about WINS, but if all you want is use IO::Socket to open a socket, make a request and read the response through it, here is a quick example:
    #!/usr/bin/perl use strict; use IO::Socket; my $host = "your.hostname.here"; my $port = 137; my $sock = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port, Proto => 'tcp' # I guess TCP is ok for you ... ); die "cannot open socket" unless ($sock); # send the request my $req = "whatever request you wish to send through the socket"; print $sock $req; # read the response while (<$sock>) { #do something with the response } close $sock; exit;

    I hope this helps.

    marcos
Re: How to make a WINS query using IO::Socket?
by choocroot (Friar) on Jun 19, 2002 at 08:35 UTC
    Perhaps you can use the nmblookup and smbclient commands from Samba to make your request without touching to sockets and the WINS protocol ...

    However, if you really want to use sockets and the WINS protocol you should read the IO::Socket::INET man page, and the RFC of the NetBIOS protocol, RFC1001 and RFC1002

      Unfortunately no...our ultimate goal is to be able to enter a username on the command line and retrieve IP addresss, machine name, etc. from that.

      WINS stores the username and will display it (via nmblookup) if supplied with an IP address, but as far as I can tell no tools have been written to go the other way.

      ....I guess I will have to read the 1000 page RFCs - Gah!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://175532]
Approved by Aristotle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-24 09:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found