/// Setup the callback for received data and loss of connection public void SetupReceiveCallback(FormGPS app) { try { AsyncCallback receiveData = new AsyncCallback(app.OnReceivedData); sock.BeginReceive(m_byBuff, 0, m_byBuff.Length, SocketFlags.None, receiveData, this); } catch (Exception ex) { app.CatchErrorMessageBox(ex.Message); } }