Data Sheet

39
ETHERIO24TCPDATASHEET
public void RecieveThread()
{
while (true)
{
//***********************************************
//Declare RemoteIPEndPoint
//where RemotIPEndPoint is the any IP address
//and Port Number of the incoming UDP packet
//***********************************************
System.Net.IPEndPoint RemoteIpEndPoint = new
System.Net.IPEndPoint(System.Net.IPAddress.Any, 0);
//***********************************************
//In remoteIPendpoint, the IP address can be changed from any specific
//IP address, and the Port, which is 0 in the above line, can be changed
//to a specific port number.
//***********************************************
//***********************************************
//Declare other variables used
//***********************************************
byte[] receiveBytes;
string returnData;
//***********************************************
//Receive incoming UDP Packet
//***********************************************
receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
returnData = System.Text.Encoding.ASCII.GetString(receiveBytes);
//***********************************************
// Test to see if there is anything to recieve
//***********************************************
if (returnData.Length != 0)
{
//***********************************************
//Filter data by IP address. If from host PC, then ignore
//else accept incoming data
//***********************************************
if ((PCIPAddress == RemoteIpEndPoint.Address.ToString()))
{
//ignore any data sent by host PC
}
else
{
if (ReturnIPAddress != RemoteIpEndPoint.Address.ToString())
{
//*********************************************
// Setup list of IP address that have responded
//*********************************************
IPList.Insert(list, RemoteIpEndPoint);
list = list + 1;
}
ReturnIPAddress = RemoteIpEndPoint.Address.ToString();
//***********************************************
//Return Data that was recieved from Ether IO24 as well as IP address
//***********************************************
ReturnUDPData(receiveBytes, RemoteIpEndPoint);
}
}
}
}
}
}
©
2013ElexolPtyLtd Revision1.3