• API Documentation
Show / Hide Table of Contents
  • Rssdp
    • AggregateSsdpDeviceLocator
    • CustomHttpHeader
    • CustomHttpHeadersCollection
    • DeviceAvailableEventArgs
    • DeviceEventArgs
    • DeviceNetworkType
    • DeviceNetworkTypeExtensions
    • DeviceUnavailableEventArgs
    • DiscoveredSsdpDevice
    • ExceptionExtensions
    • ISsdpLogger
    • NullLogger
    • ServiceEventArgs
    • SocketClosedException
    • SocketFactory
    • SsdpDevice
    • SsdpDeviceExtensions
    • SsdpDeviceIcon
    • SsdpDeviceLocator
    • SsdpDevicePropertiesCollection
    • SsdpDeviceProperty
    • SsdpDevicePublisher
    • SsdpEmbeddedDevice
    • SsdpRootDevice
    • SsdpService
    • SsdpStandardsMode
    • SsdpTraceLogger
  • Rssdp.Infrastructure
    • DisposableManagedObjectBase
    • HttpParserBase<T>
    • HttpRequestParser
    • HttpResponseParser
    • ISocketFactory
    • ISsdpCommunicationsServer
    • ISsdpDeviceLocator
    • ISsdpDevicePublisher
    • IUdpSocket
    • IUpnpDeviceValidator
    • ReceivedUdpData
    • RequestReceivedEventArgs
    • ResponseReceivedEventArgs
    • SsdpCommunicationsServer
    • SsdpConstants
    • SsdpDeviceLocatorBase
    • SsdpDevicePublisherBase
    • UdpEndPoint
    • Upnp10DeviceValidator

Class SsdpCommunicationsServer

Provides the platform independent logic for publishing device existence and responding to search requests.

Inheritance
System.Object
DisposableManagedObjectBase
SsdpCommunicationsServer
Implements
ISsdpCommunicationsServer
System.IDisposable
Inherited Members
DisposableManagedObjectBase.ThrowIfDisposed()
DisposableManagedObjectBase.IsDisposed
DisposableManagedObjectBase.Dispose()
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Rssdp.Infrastructure
Assembly: cs.temp.dll.dll
Syntax
public sealed class SsdpCommunicationsServer : DisposableManagedObjectBase, ISsdpCommunicationsServer, IDisposable

Constructors

SsdpCommunicationsServer(ISocketFactory)

Minimum constructor.

Declaration
public SsdpCommunicationsServer(ISocketFactory socketFactory)
Parameters
Type Name Description
ISocketFactory socketFactory

An implementation of the ISocketFactory interface that can be used to make new unicast and multicast sockets. Cannot be null.

Exceptions
Type Condition
System.ArgumentNullException

The socketFactory argument is null.

SsdpCommunicationsServer(ISocketFactory, Int32)

Partial constructor.

Declaration
public SsdpCommunicationsServer(ISocketFactory socketFactory, int localPort)
Parameters
Type Name Description
ISocketFactory socketFactory

An implementation of the ISocketFactory interface that can be used to make new unicast and multicast sockets. Cannot be null.

System.Int32 localPort

The specific local port to use for all sockets created by this instance. Specify zero to indicate the system should choose a free port itself.

Exceptions
Type Condition
System.ArgumentNullException

The socketFactory argument is null.

SsdpCommunicationsServer(ISocketFactory, Int32, Int32)

Full constructor.

Declaration
public SsdpCommunicationsServer(ISocketFactory socketFactory, int localPort, int multicastTimeToLive)
Parameters
Type Name Description
ISocketFactory socketFactory

An implementation of the ISocketFactory interface that can be used to make new unicast and multicast sockets. Cannot be null.

System.Int32 localPort

The specific local port to use for all sockets created by this instance. Specify zero to indicate the system should choose a free port itself.

System.Int32 multicastTimeToLive

The multicast time to live value for multicast sockets. Technically this is a number of router hops, not a 'Time'. Must be greater than zero.

Exceptions
Type Condition
System.ArgumentNullException

The socketFactory argument is null.

System.ArgumentOutOfRangeException

The multicastTimeToLive argument is less than or equal to zero.

Properties

DeviceNetworkType

What type of sockets will be created: ipv6 or ipv4

Declaration
public DeviceNetworkType DeviceNetworkType { get; }
Property Value
Type Description
DeviceNetworkType

IsShared

Gets or sets a boolean value indicating whether or not this instance is shared amongst multiple SsdpDeviceLocatorBase and/or ISsdpDevicePublisher instances.

Declaration
public bool IsShared { get; set; }
Property Value
Type Description
System.Boolean
Remarks

If true, disposing an instance of a SsdpDeviceLocatorBaseor a ISsdpDevicePublisher will not dispose this comms server instance. The calling code is responsible for managing the lifetime of the server.

UdpSendCount

The number of times the Udp message is sent. Any value less than 2 will result in one message being sent. SSDP spec recommends sending messages multiple times (not more than 3) to account for possible packet loss over UDP.

Declaration
public int UdpSendCount { get; set; }
Property Value
Type Description
System.Int32
See Also
UdpSendDelay

UdpSendDelay

The delay between repeating messages (as specified in UdpSendCount).

Declaration
public TimeSpan UdpSendDelay { get; set; }
Property Value
Type Description
System.TimeSpan
See Also
UdpSendCount

Methods

BeginListeningForBroadcasts()

Causes the server to begin listening for multicast messages, being SSDP search requests and notifications.

Declaration
public void BeginListeningForBroadcasts()
Exceptions
Type Condition
System.ObjectDisposedException

Thrown if the IsDisposed property is true (because Dispose() has been called previously).

Dispose(Boolean)

Stops listening for requests, disposes this instance and all internal resources.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
System.Boolean disposing
Overrides
DisposableManagedObjectBase.Dispose(Boolean)

SendMessage(Byte[], UdpEndPoint)

Sends a message to a particular address (uni or multicast) and port.

Declaration
public void SendMessage(byte[] messageData, UdpEndPoint destination)
Parameters
Type Name Description
System.Byte[] messageData

A byte array containing the data to send.

UdpEndPoint destination

A UdpEndPoint representing the destination address for the data. Can be either a multicast or unicast destination.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if the messageData argument is null.

System.ObjectDisposedException

Thrown if the IsDisposed property is true (because Dispose() has been called previously).

StopListeningForBroadcasts()

Causes the server to stop listening for multicast messages, being SSDP search requests and notifications.

Declaration
public void StopListeningForBroadcasts()
Exceptions
Type Condition
System.ObjectDisposedException

Thrown if the IsDisposed property is true (because Dispose() has been called previously).

StopListeningForResponses()

Stops listening for search responses on the local, unicast socket.

Declaration
public void StopListeningForResponses()
Exceptions
Type Condition
System.ObjectDisposedException

Thrown if the IsDisposed property is true (because Dispose() has been called previously).

Events

RequestReceived

Raised when a HTTPU request message is received by a socket (unicast or multicast).

Declaration
public event EventHandler<RequestReceivedEventArgs> RequestReceived
Event Type
Type Description
System.EventHandler<RequestReceivedEventArgs>

ResponseReceived

Raised when an HTTPU response message is received by a socket (unicast or multicast).

Declaration
public event EventHandler<ResponseReceivedEventArgs> ResponseReceived
Event Type
Type Description
System.EventHandler<ResponseReceivedEventArgs>

Implements

ISsdpCommunicationsServer
System.IDisposable
In This Article
Back to top Copyright (c) 2015 Troy Willmot