2

I have device (TCP/IP network controller) which is connect to my network router. To that controller is connected fingerprint scanner. What i want to do is get data of scanned finger into my c# code.

I have tried using TCP Listner but nothing happened (no error or anything lese)

I have dll file from that product but there are lot of code in it and i am new to this so i overlooked something. Inside that dll i tried searching for some EventHandler (thought that is listening or responding when finger is placed on scanner) but there is not even one of it.

What should i look for or how should i listen to data that get's sent from that device.

Here is DLL File: Download Link

I know this may be too broad but please give me some hints, i am trying this for few days and still can't figure it out.

Code i tried:

namespace ConsoleApplication1
{
    public class Program
    {
        static void Main(string[] args)
        {
            TcpListener server = null;
            try
            {
                // Set the TcpListener on port 60000.
                Int32 port = 60000;

                // TcpListener server = new TcpListener(port);
                server = new TcpListener(port);

                // Start listening for client requests.
                server.Start();

                // Buffer for reading data
                Byte[] bytes = new Byte[256];
                String data = null;

                // Enter the listening loop.
                while (true)
                {
                    Console.Write("Waiting for a connection... ");

                    // Perform a blocking call to accept requests.
                    // You could also user server.AcceptSocket() here.
                    TcpClient client = server.AcceptTcpClient();
                    Console.WriteLine("Connected!");

                    data = null;

                    // Get a stream object for reading and writing
                    NetworkStream stream = client.GetStream();

                    int i;

                    // Loop to receive all the data sent by the client.
                    while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
                    {
                        // Translate data bytes to a ASCII string.
                        data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
                        Console.WriteLine("Received: {0}", data);

                        // Process the data sent by the client.
                        data = data.ToUpper();

                        byte[] msg = System.Text.Encoding.ASCII.GetBytes(data);

                        // Send back a response.
                        stream.Write(msg, 0, msg.Length);
                        Console.WriteLine("Sent: {0}", data);
                    }

                    // Shutdown and end connection
                    client.Close();
                }
            }
            catch (SocketException e)
            {
                Console.WriteLine("SocketException: {0}", e);
            }
            finally
            {
                // Stop listening for new clients.
                server.Stop();
            }


            Console.WriteLine("\nHit enter to continue...");
            Console.Read();
        }
    }
}

Product i am having: LINK

Couldn't find any documentation for it.

  • Please at least provide the code you have tried. What is the device brand and model? Any documentation for that specific device? – Mathieu de Lorimier Mar 19 '18 at 13:48
  • Couldn't find any documentation. Device and some code are in edited question – Aleksa Ristic Mar 19 '18 at 14:04
  • The device is the listener and needs to be started first. You connect using a TCPClient. See msdn examples. The example are for Socket class but you can use any class that inherits the socket class like TCPClient : https://learn.microsoft.com/en-us/dotnet/framework/network-programming/socket-code-examples – jdweng Mar 19 '18 at 14:09
  • @jdweng If i understand you, second example suits me `Synchronous Server Socket Example` but how do i specify what i need to catch and from where? My device is at ip: `192.168.2.36` with port `60000` but how to know what to catch and where to specify it? – Aleksa Ristic Mar 19 '18 at 15:01
  • Use : IPHostEntry ipHostInfo = Dns.GetHostEntry("192.168.2.36"); – jdweng Mar 19 '18 at 15:08
  • `No such host is known` - this error i get – Aleksa Ristic Mar 19 '18 at 15:40
  • Possible duplicate of [Server Client send/receive simple text](https://stackoverflow.com/questions/10182751/server-client-send-receive-simple-text) –  Mar 20 '18 at 17:49

0 Answers0