0

I am trying to connect to my RFID printronix printer using sockets with this code :

if (ep == null)
{
    ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9001);  
}
socket = new Socket(ep.AddressFamily,
                    SocketType.Stream,
                    ProtocolType.Tcp);
socket.Connect(ep);

I am using port 9001 because this is usually standard port for printers, however, when i look at printer properties I see it is using USB001, which is the virtual usb port.

I receive this error I'm assuming because of the port number.

No connection could be made because the target machine actively refused it 127.0.0.1:9001

How do I retrieve port number for this printer. If that is not the error, please help. Thanks.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Lucky Luke2
  • 2,056
  • 5
  • 25
  • 32
  • Can u verify by running as admin. Due to UAC settings you are not allowed to open ports unless running as admin. – Dinesh Nov 12 '13 at 08:31
  • @Dinesh thanks but still get the error. – Lucky Luke2 Nov 12 '13 at 08:37
  • Thanks what you can try...run this command -> "netstat -a" or "netstat -ao" and check to make sure that indeed your printer is listening on 9001 port. If not on 9001 you can check the other entries if any of them matches your printer. – Dinesh Nov 12 '13 at 08:40
  • @Dinesh how do i know which is my printer. sorry – Lucky Luke2 Nov 12 '13 at 08:48
  • .NET does not have native support for USB communication. The best i can think of is you should look at answer here http://stackoverflow.com/a/68827/448407 – Dinesh Nov 12 '13 at 11:24

0 Answers0