private void PostInitialize() { // If UDP port set then init UDP connection if (Settings.UdpPort > 0) { UdpSocket.Bind(Settings.Host, Settings.UdpPort); } }
/// <summary> /// Initializes the connection with LFS. /// </summary> /// <param name="settings">A <see cref="InSimSettings"/> object containing information to initialize the connection with.</param> public void Initialize(InSimSettings settings) { if (settings == null) { throw new ArgumentNullException("settings"); } ThrowIfDisposed(); ThrowIfConnected(); Settings = new ReadOnlyInSimSettings(settings); try { if (Settings.IsRelayHost) { TcpSocket.Connect(RelayHost, RelayPort); } else { TcpSocket.Connect(Settings.Host, Settings.Port); Send(new IS_ISI { Admin = Settings.Admin, Flags = Settings.Flags, IName = Settings.IName, Interval = Settings.Interval, Prefix = Settings.Prefix, ReqI = 1, // Request version. UDPPort = Settings.UdpPort, }); if (Settings.UdpPort > 0) { UdpSocket.Bind(Settings.Host, Settings.UdpPort); } } OnInitialized(new InitializeEventArgs(Settings)); } catch (SocketException ex) { if (ex.SocketErrorCode == SocketError.ConnectionRefused) { throw new InSimException(StringResources.InSimCouldNotConnectMessage, ex); } throw; } }