Support Home


Knowledge Base


Documentation


Contact Support


Unofficial Forum

Getting An IP Address Using X Command Only

Question: We know that “X” command returns the MAC-address of the DS100/EM100. When sent in the broadcast mode, it can be used to collect the replies from all locally attached Device Servers. But why this command doesn't return the IP-address of the DS100/EM100 as well? So, how do I find out which IP-addresses correspond to the MAC-addresses of the Device Servers that have replied to my broadcast?

Answer: The IP-address is not explicitly returned in the reply to the “X” command because it can be obtained from the OS after the reply UDP datagram is processed. For example, in VB6, you use the WinSock ActiveX Control to communicate with the DS100/EM100. Here is a fragment of a sample code. This fragment is a handler for the WinSock_DataArrival event. This event is generated each time the data arrives from the remote host(s).

Private Sub WinSock_DataArrival(ByVal bytesTotal As Long)
 
      WinSock.GetData s$      'this copies the contents of the entire UDP datagram
      ip$=WinSock.RemoteHostIP    'this copies the IP-address of the sender into ip$

End Sub

No matter how many replies from different hosts the program receives the IP-address of each host can be accurately retrieved using the code shown above.


© Tibbo Technology Inc. 2001-2009   Contact Us | Account