Я пишу программу для чтения данных с терминала IND 560.Терминал IND 560 - это устройство для взвешивания груза и отображения веса.Устройство подключено к ПК (10.6.16.166) через Ethernet.Ниже приведен код, который я написал
public Socket m_socListener;
public AsyncCallback temcallback;
public void getdata
{
m_socListener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPAddress ipaddress = CreateIPAddress("10.6.16.166");
IPEndPoint iplocal = new IPEndPoint(ipaddress, 1780);
m_socListener.Bind(iplocal);
m_socListener.Listen(4);
m_socListener.BeginAccept(new AsyncCallback(OnDeviceConnect), m_socListener);
}
public void OnDeviceConnect(IAsyncResult async)
{
m_socworker = m_socListener.EndAccept(async);
WaitforWeight(m_socworker); // This is another function
}
public IPAddress CreateIPAddress(string ipadd)
{
return IPAddress.Parse(ipadd);
}
The Problem here is when I execute the line BeginAccept method it is not calling the function "OnDeviceConnect" just it is executing BeginAccept and stepout to the next line. Am I doing anything wrong in here. Any suggestions would be greatly appreciated