コード例 #1
0
        private void DoStartListening()
        {
            try
            {
                deviceReceiveBuffer = new DeviceReceiveBuffer();
                deviceReceiveBuffer.SetCallback(onReceiveMessage);
                GetCertificate();
                Disposed = false;

                IPEndPoint localEndPoint = new IPEndPoint(ipAddress, port);
                if (localEndPoint != null && cert != null)
                {
                    listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                    if (listener != null)
                    {
                        listener.Bind(localEndPoint);
                        listener.Listen(100);
                        listener.BeginAccept(new AsyncCallback(AcceptCallback), listener);
                        logger.Log($"Listening {ipAddress}:{port}");
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Log(ex, "DeviceListener.DoStartListening");
            }
        }
 public DeviceConnection(ILogger loggerIn, IDeviceReceiveBuffer deviceReceiveBufferIn)
 {
     logger = loggerIn;
     deviceReceiveBuffer = deviceReceiveBufferIn;
     deviceReceiveBuffer.SetCallback(OnReceiveMessage);
 }