Click here to Skip to main content
14,662,534 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi, I'll make this short as possible..

I'm trying to communicate with boom barrier machine the connection is okay but in physically the barrier does not lift up this happens sometimes is there a way for me to know if the machine work or not? i only pass an IP address and a port to make it work..
btw I'm using c#..

try
           {
               zkemkeeper.CZKEM zk = new zkemkeeper.CZKEM();
               bool connected = false;
               int PortNo = 4370;
               connected = zk.Connect_Net(globalVariables.boomGateIP, PortNo);
               if (connected)
               {
                   if (zk.ACUnlock(1, 100))
                   {
                       GatesRepository gateRepository = new GatesRepository();
                       string hostName = Dns.GetHostName();
                       gateRepository.OpenBoom(globalVariables.Username,  Settings.Default.BoothId, "", "", getIP.getHostName(), hostName, txtContainernumber.Text);
                   }
                   else
                   {
                       MessageBox.Show("error opening boom gate door.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                   }
                   zk.Disconnect();
               }
               else
               {
                   MessageBox.Show("error connecting with boom gate device. call it", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
               }
           }
           catch (Exception ex)
           {
               MessageBox.Show(ex.Message);
           }


What I have tried:

i tried a for loop but the problem is still there, i'm really out of option guys.. I'm drained..
Posted
Updated 23-Sep-20 20:14pm
v3

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

I always Ping before connecting or trying to reconnect.

Ping Class (System.Net.NetworkInformation) | Microsoft Docs[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100