How to communicate with a device connected in lan

1

Good, I'm fiddling with a biometric fingerprint sensor, my intention is to get the data through a program. But I've found that to begin with, even though I can ping him, I can not communicate with him using the Socket class.

static void ProbarConexion(){

            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
   ProtocolType.Tcp);


            s.Connect("192.168.1.224", 52925);

            if (!s.Connected)
            {
                Console.WriteLine("Imposible conectar");
            }

            if (s.Poll(-1, SelectMode.SelectWrite))
            {
                Console.WriteLine("Se puede escribir");
            }
            else if (s.Poll(-1, SelectMode.SelectRead))
            {
                Console.WriteLine("Se puede leer");
            }
            else if (s.Poll(-1, SelectMode.SelectError))
            {
                Console.WriteLine("Error");
            }

        }

Any ideas? From that code, I'm missing an exception that could not be answered.

Say that in the device I have it configured with the ip address and the port that I have put in the code, come on, that ping using the cmd goes well.

    
asked by Kino 17.03.2016 в 12:48
source

2 answers

1

> > the device uses a protocol of type ARP,

You could use windows api to send by ARP

Create page SendARP (iphlpapi)

defines

 [DllImport("iphlpapi.dll", ExactSpelling=true)]
 public static extern int SendARP(
    uint DestIP, uint SrcIP, byte[] pMacAddr, ref int PhyAddrLen);

The weird thing is that this is not used to send data to a device

Protocol address resolution

See what the wiki says

  

The ARP protocol is responsible for translating IP addresses to MAC addresses (physical addresses). To perform this conversion, the link level uses the ARP tables, each interface has both an IP address and a MAC physical address.

    
answered by 17.03.2016 в 16:17
0

I understand that those biometric devices have their own communication program, and you're sure trying to "hack" it.

I recommend that you download wireshark, put it to record, and communicate the manufacturer program with the device, that way you can see the port, protocol (TCP or UDP), and maybe some detail of how to do commands

    
answered by 17.03.2016 в 12:59