public virtual void Open()

in FixAntenna/NetCore/FixEngine/Transport/Client/Udp/UdpTransport.cs [76:148]


		public virtual void Open()
		{
			try
			{
				_inetAddress = new IPEndPoint(IPAddress.Parse(_multicastAddress), _port);
				_socket = new Socket(SocketType.Dgram, ProtocolType.Udp);

				if (_bufferSize > 0)
				{
					if (_log.IsDebugEnabled)
					{
						_log.Debug("Change the default DatagramSocket buffer from " + _socket.ReceiveBufferSize + " to " +
									_bufferSize);
					}

					_socket.ReceiveBufferSize = _bufferSize;
				}

				_socket.Bind(new IPEndPoint(IPAddress.Any, _port));

				if (_networkInterface == null)
				{
					if (_log.IsDebugEnabled)
					{
						_log.Debug("Join group " + _inetAddress);
					}

					McastOption = new MulticastOption(_inetAddress.Address);
				}
				else
				{
					Intf = GetNetworkInterfaceByName(_networkInterface);
					var index = -1;
					if (Intf.SupportsMulticast)
					{
						if (Intf.Supports(NetworkInterfaceComponent.IPv4))
						{
							index = Intf.GetIPProperties().GetIPv4Properties().Index;
						}
					}

					if (index >= 0)
					{
						if (_log.IsDebugEnabled)
						{
							_log.Debug("Join group " + _inetAddress + " on interface " + Intf.ToString());
						}

						McastOption = new MulticastOption(_inetAddress.Address, index);
					}
					else
					{
						if (_log.IsDebugEnabled)
						{
							_log.Debug("Join group " + _inetAddress + ". Interface " + Intf.ToString() +
										"is specified but it is not multicast capable, ignore it.");
						}

						McastOption = new MulticastOption(_inetAddress.Address);
					}
				}

				_socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, McastOption);
				_udpClient = new UdpClient
				{
					Client = _socket
				};
			}
			catch (SocketException ex)
			{
				throw new IOException(ex.Message, ex);
			}
		}