Networking :: How do you check a network port is open?



Well - both machines connect to google and from netstat, the sane port on 6566 looks to be open, but...
I guess the solution (as it often is) was a matter of finding the correct error log to look in:
Code Sample
$ scanimage -L
[/var/log/messages]
Sep 18 15:16:43 box daemon.err inetd[1572]: getpwnam: saned: No such user

So, by changing the following (on the server as a test):

/etc/inetd.conf
sane-port stream tcp nowait saned.saned /opt/hplip/sbin/saned saned -->
--> sane-port stream tcp nowait root /opt/hplip/sbin/saned saned

/etc/saned/net.conf
localhost

/etc/saned/dll.conf
net
hpaio

Then it all falls into place:
Code Sample
$ sudo /etc/init.d/inetd restart
$ telnet localhost 6566
Trying 127.0.0.1...
Connected to box.
Escape character is '^]'.
^]
Connection closed by foreign host.
$ scanimage -L
device `hpaio:/usb/OfficeJet_K80?serial=ES0911401VOH' is a Hewlett-Packard OfficeJet_K80 all-in-one
device `net:localhost:hpaio:/usb/OfficeJet_K80?serial=ES0911401VOH' is a Hewlett-Packard OfficeJet_K80 all-in-one
$ scanimage -d net:localhost:hpaio:/usb/OfficeJet_K80?serial=ES0911401VOH --test
scanimage: scanning image of size 638x1125 pixels at 24 bits/pixel
scanimage: acquiring RGB frame, 8 bits/sample
scanimage: reading one scanline, 1914 bytes...  PASS
scanimage: reading one byte...          PASS
scanimage: stepped read, 2 bytes...     PASS
...

Now to try it from dsl and winxp clients...

Well... winxp doesn't want to scan remotely (so far), w2k works fine (and into photoshop via sanetwain - result) and it works from a remote dsl machine:
Code Sample
$ telnet 192.168.1.100 6566
Trying 192.168.1.100...
Connected to 192.168.1.100.
Escape character is '^]'.
^]
Connection closed by foreign host.
$ export PATH=/opt/hplip/bin:/opt/python-2.3/bin:$PATH
$ scanimage -L
device `net:192.168.1.100:hpaio:/usb/OfficeJet_G85?serial=SGG13E0C49VL' is a Hewlett-Packard OfficeJet_G85 all-in-one
$ scanimage --test
scanimage: scanning image of size 638x877 pixels at 24 bits/pixel
scanimage: acquiring RGB frame, 8 bits/sample
scanimage: reading one scanline, 1914 bytes...  PASS
scanimage: reading one byte...          PASS
scanimage: stepped read, 2 bytes...     PASS
scanimage: stepped read, 4 bytes...     PASS
yada yada
scanimage: stepped read, 3 bytes...     PASS
...not so fast over a wireless connection though  :)

...found the problem with winxp - something about the way it connects to saned (as compared to w2k) didn't like:
Code Sample

$ cat /etc/sane.d/saned.conf
192.168.1.1/120
$ sudo /opt/hplip/sbin/saned -d128
[saned] main: starting debug mode (level 128)
...
[saned] main: [1] bind () to port 6566
[saned] main: [1] listen ()
[saned] main: waiting for control connection
[saned] saned (AF-indep+IPv6) from sane-backends 1.0.18 ready
[saned] check_host: access by remote host: 192.168.1.102
[saned] check_host: remote host is not IN_LOOPBACK nor IN6_LOOPBACK
[saned] check_host: local hostname: box
[saned] check_host: local hostname(s) (from DNS): box
[saned] check_host: remote host doesn't have same addr as local
[saned] check_host: opening config file: saned.conf
[saned] check_host: config file line: `192.168.1.1/120'
[saned] check_host: subnet with base IP = 192.168.1.1, CIDR netmask = 120
[saned] check_v4_in_range: invalid CIDR value (120) !
[saned] init: access by host 192.168.1.102 denied
[saned] quit: exiting


but naming the client ip address exlicitly did it:
Code Sample
$ cat /etc/sane.d/saned.conf
192.168.1.102
192.168.1.1/120
$ sudo /opt/hplip/sbin/saned -d128
...
[saned] main: [1] bind () to port 6566
[saned] main: [1] listen ()
[saned] main: waiting for control connection
[saned] saned (AF-indep+IPv6) from sane-backends 1.0.18 ready
[saned] check_host: access by remote host: 192.168.1.102
[saned] check_host: remote host is not IN_LOOPBACK nor IN6_LOOPBACK
[saned] check_host: local hostname: box
[saned] check_host: local hostname(s) (from DNS): box
[saned] check_host: remote host doesn't have same addr as local
[saned] check_host: opening config file: saned.conf
[saned] check_host: config file line: `192.168.1.102'
[saned] check_host: access granted from IP address 192.168.1.102
[saned] init: access granted

Its kind of odd that w2k doesn't have the same problem. Anyway, it works and the really good bit is that windows cannot share scanners natively...


original here.