private bool disposedValue = false; // To detect redundant calls // IDisposable protected virtual void Dispose(bool disposing) { if (!this.disposedValue) { if (disposing) { // TODO: free other state (managed objects). try { //closes the listening port this._BroadCastlisteningSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DropMembership, new MulticastOption(this._mcIP, IPAddress.Any)); this._BroadCastlisteningSocket.Close(); } catch (Exception) { } try { _DataBroadCastHostServer = null; } catch (Exception) { } } // TODO: free your own state (unmanaged objects). // TODO: set large fields to null. } this.disposedValue = true; }
public void broadCastTestForm_Load(System.Object sender, System.EventArgs e) { try { _broadCastDataReceiver = new DataBroadcastListener(BROAD_CAST_IP_ADDRESS, BROAD_CAST_PORT); _broadCastDataReceiver.DataReceived += DataReceived; } catch (Exception) { } }
public DiscoverableServiceDefinitionHandlingServer(DiscoverableServiceHandlingOperativeDefs.DiscoverableServiceMode serviceMode, string serviceName, DiscoverableServiceDefinitionParametersContainer parameters) { this._serviceName = serviceName.ToUpper(); this._serviceID = Guid.NewGuid().ToString("N"); this._servideMode = serviceMode; this._serviceParameters = parameters; //adds the service name, its id and its operation mode in the parameters Table //in order to reply the table within the broadcast reply as a hashtable and //retrieve those parametes in the client to fill specific fiels of the structure DiscoverableServiceDefinition this._serviceParameters.AddParameter(DiscoverableServiceHandlingOperativeDefs.SERVICE_NAME, this._serviceName); this._serviceParameters.AddParameter(DiscoverableServiceHandlingOperativeDefs.SERVICE_ID, this._serviceID); this._serviceParameters.AddParameter(DiscoverableServiceHandlingOperativeDefs.SERVICE_OPERATION_MODE, DiscoverableServiceHandlingOperativeDefs.GetServiceOperationModeAsString(this._servideMode)); this._clientQueriesReceived = 0; this._succesfullQueriesResulted = 0; //Me._broadcastListener = BroadCasting.DataBroadcastListener.GetInstance this._broadcastListener = new DataBroadcastListener(DiscoverableServiceHandlingOperativeDefs.DHS_SERVICE_HANDLER_BROADCAST_IP_ADDRESS, DiscoverableServiceHandlingOperativeDefs.DSH_SERVICE_HANDLER_BROADCAST_TCP_PORT); this._broadcastListener.DataReceived += this.broadcastDataReceived; }