Ejemplo n.º 1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="OscOutboundUpdStream" /> class.
        /// </summary>
        /// <param name="endPoint">The end point.</param>
        /// <param name="scheduler">The scheduler.</param>
        /// <exception cref="System.ArgumentNullException">endPoint</exception>
        /// <exception cref="System.InvalidOperationException">This Stream supports only unicat udp endpoints</exception>
        public OscOutboundUpdStream(OscEndPoint endPoint, IScheduler scheduler) : base(scheduler)
        {
            if (endPoint == null)
            {
                throw new ArgumentNullException("endPoint");
            }

            if (endPoint.TransportType != TransportType.Udp)
            {
                throw new InvalidOperationException("This Stream supports only udp endpoints");
            }


            m_endPoint = endPoint;
            m_socket   = new Socket(m_endPoint.EndPoint.Address.AddressFamily, SocketType.Dgram, ProtocolType.Udp);


            if (endPoint.TransmissionType == TransmissionType.Multicast)
            {
                //224.0.0.0-239.255.255.255
                var range = IPAddressRange.MulticastRange;

                if (range.IsInRange(m_endPoint.EndPoint.Address))
                {
                    // setup multicast
                    m_socket.SetSocketOption(
                        SocketOptionLevel.IP,
                        SocketOptionName.AddMembership,
                        new MulticastOption(m_endPoint.EndPoint.Address));

                    // join multicast group
                    m_socket.SetSocketOption(
                        SocketOptionLevel.IP,
                        SocketOptionName.MulticastTimeToLive,
                        5);
                }
                else
                {
                    throw new InvalidOperationException("Address is not in multicast address range");
                }
            }
            else if (m_endPoint.TransmissionType == TransmissionType.Broadcast)
            {
                // setup broadcast
                m_socket.SetSocketOption(
                    SocketOptionLevel.Socket,
                    SocketOptionName.Broadcast,
                    true);
            }
        }
Ejemplo n.º 2
0
        public OscOutboundTcpStream(OscEndPoint endPoint, IScheduler scheduler) : base(scheduler)
        {
            if (endPoint == null)
            {
                throw new ArgumentNullException("endPoint");
            }

            if (endPoint.TransportType != TransportType.Tcp)
            {
                throw new InvalidOperationException("This Stream supports only tcp endpoints");
            }

            m_socket = new Socket(endPoint.EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            m_socket.Connect(endPoint.EndPoint);
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="OscInboundTcpStream" /> class.
 /// </summary>
 /// <param name="endPoint">The end point.</param>
 /// <param name="scheduler">The scheduler.</param>
 public OscInboundTcpStream(OscEndPoint endPoint, IScheduler scheduler = null) : base(scheduler)
 {
     m_endPoint = endPoint;
 }