/// <summary> /// Initializes a new instance of the <see cref="EpicsUDPConnection"/> class. /// </summary> /// <param name="ipe"> /// The ipe. /// </param> internal EpicsUDPConnection(IPEndPoint ipe) { this.UDPSocket = UDPSocketManager.GetSocket(ipe); /*UDPSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); * UDPSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); * UDPSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); * UDPSocket.Bind(ipe);*/ this.Start(); }
/// <summary> /// Initializes a new instance of the <see cref = "EpicsUDPConnection" /> class. /// Client Constructor, will try to get his Port automaticly /// </summary> internal EpicsUDPConnection() { this.UDPSocket = UDPSocketManager.GetSocket(); /*UDPSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); * UDPSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); * UDPSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); * * //do a stupid send so that it get's himself an endpoint * UDPSocket.SendTo(new byte[1]{0}, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 60000));*/ this.Start(); }
/// <summary> /// The start. /// </summary> private void Start() { UDPSocketManager.Listen(this.UDPSocket, this.Listen); /*//start Receiver * tReceiver = new Thread(Listen); * tReceiver.IsBackground = true; * tReceiver.Start();*/ // start Handler this.tHandler = new Thread(this.Handle); this.tHandler.IsBackground = true; this.tHandler.Start(); }
/// <summary> /// The dispose. /// </summary> public void Dispose() { if (this.notDisposing) { this.notDisposing = false; } else { return; } /*UDPSocket.Close(); * UDPSocket = null;*/ UDPSocketManager.StopListen(this.UDPSocket, this.Listen); UDPSocketManager.DisposeSocket(this.UDPSocket); }