private static void Listening(object state) { UDPDuplexListener listener = (UDPDuplexListener)state; UDPListener udpListener = new UDPListener(new IPEndPoint(IPAddress.Loopback, 13001), 2); try { udpListener.Start(); if (listener.started != null) { listener.started(); } Console.WriteLine("Servidor de áudio iniciado na porta " + udpListener.LocalIPEndPoint.Port.ToString()); while (true) { UDPClient client = udpListener.AcceptClient(); listener.clientAccepted(new UDPDuplexCommunication(client)); } } catch (SocketException e) { Console.WriteLine("SocketException: {0}", e); } finally { // Stop listening for new clients. udpListener.Stop(); } }
/// <summary> /// /// </summary> void StartListening() { UDPListener listener = new UDPListener(this); listener.Start(); Console.ReadKey(); listener.Stop(); }
void Start() { if (m_ServerSession.Init("127.0.0.1", 30000)) { m_ServerSession.Start(); } if (m_ClientSession.Init("127.0.0.1", 30000)) { m_ClientSession.Start(); } }
void RunUDPServer() { UDPListener listener = new UDPListener(NetworkingLibaryStandard.NetworkingLibaryStandard.DefaultPortNumber, this); listener.Start(); Console.WriteLine("Press any Key to stop"); Console.ReadKey(); listener.Stop(); Console.WriteLine("They System Has stoped"); }
public void StartServer(bool isSingleplayer = false) { if (!NetTools.isSingleplayer) { SteamInteraction.instance.StartServer(); } if (NetworkData.instance != null) { NetworkData.instance.GeneratePooledObjects(); } else { Debug.LogWarning("There is no loaded NetworkData in the scene. This may break some features."); } if (NetTools.isSingleplayer) { NetTools.clientID = 0; NetTools.isServer = true; UnityPacketHandler.instance.StartHandler(); Debug.Log("Server started in Singleplayer Mode."); return; } connectionsByID = new Dictionary <int, NetworkPlayer>(); //Create server //Debug.Log(IPAddress.Parse(hostAddress)); if (hostAddress == "Any") { server = new TcpListener(IPAddress.Any, hostPort); } else { server = new TcpListener(IPAddress.Parse(hostAddress), hostPort); } udpListener = new UDPListener(this); server.Start(); udpListener.Start(); Debug.Log("Server started successfully."); NetTools.isServer = true; UnityPacketHandler.instance.StartHandler(); connectionHandler = new Thread(new ThreadStart(ConnectionHandler)); connectionHandler.Name = "ENSServerConnectionHandler"; connectionHandler.Start(); udpHandler = new Thread(new ThreadStart(UDPHandler)); udpHandler.Name = "ENSServerUDPHandler"; udpHandler.Start(); //packetSendHandler = new Thread(new ThreadStart(SendingPacketHandler)); //packetSendHandler.Start(); }
void Start() { if (m_ServerSession.Init("127.0.0.1", 30000)) { m_ServerSession.Start(); } if (m_ClientSession.Init("127.0.0.1", 30000)) { m_ClientSession.Start(); } m_ClientSession.Send(new byte[] { 0 }); }
private void StartPolling() { pollOnceToolStripMenuItem.Enabled = false; startPollingToolStripMenuItem.Enabled = false; stopPollingToolStripMenuItem.Enabled = true; timer1.Enabled = true; UDPListener.Start(hogKeysPort); if (typeof(IOutputs).IsAssignableFrom(pokeys.Driver.GetType())) { IOutputs driver = (IOutputs)pokeys.Driver; UDPListener.MessageReceived += new UDPListener.UDPListenerEventHandler(driver.UDPListenerEventHandlerMessageReceived); } pollingStatusLabel.Text = "Polling:ON"; }
/// <summary> /// /// </summary> void RunUDPDemoToms() { UDPClient client = new UDPClient(this); UDPListener listener = new UDPListener(NetworkingLibaryStandard.NetworkingLibaryStandard.DefaultPortNumber + 1, this); listener.Start(); client.Start(); client.Send("Hello World"); Console.ReadKey(); client.Disconnect(); listener.Stop(); }
void Start() { ip = Configuration.GetInnerTextByTagName("ip", ip); port = (int)Configuration.GetInnerTextByTagName("senderPort", port); listenerPort = (int)Configuration.GetInnerTextByTagName("listenerPort", listenerPort); maxTimeUntilStandby = (float)Configuration.GetInnerTextByTagName("maxTimeUntilStandby ", maxTimeUntilStandby); delayStartPlaying = (float)Configuration.GetInnerTextByTagName("delayStartPlaying ", delayStartPlaying); listener = new UDPListener(); listener.MessageReceived += OnMessage; listener.Start(listenerPort); inputManager = InputManager.GetInstance(); TextProvider.Load("text_9681.xlsx"); TextProvider.lang = "de"; StartStandbymodus(); }
void StartListener() { listener = new UDPListener(); listener.OnMessageReceived += MessageReceived; listener.Start(); }
protected void Reload() { Encryption.RNG.Reload(); // some logic in configuration updated the config when saving, we need to read it again _config = Configuration.Load(); Configuration.Process(ref _config); NLogConfig.LoadConfiguration(); logger.Info($"WPF Localization Extension|Current culture: {LocalizeDictionary.CurrentCulture}"); // set User-Agent for httpClient try { if (!string.IsNullOrWhiteSpace(_config.userAgentString)) { httpClient.DefaultRequestHeaders.Add("User-Agent", _config.userAgentString); } } catch { // reset userAgent to default and reapply Configuration.ResetUserAgent(_config); httpClient.DefaultRequestHeaders.Add("User-Agent", _config.userAgentString); } privoxyRunner = privoxyRunner ?? new PrivoxyRunner(); _pacDaemon = _pacDaemon ?? new PACDaemon(_config); _pacDaemon.PACFileChanged += PacDaemon_PACFileChanged; _pacDaemon.UserRuleFileChanged += PacDaemon_UserRuleFileChanged; _pacServer = _pacServer ?? new PACServer(_pacDaemon); _pacServer.UpdatePACURL(_config); // So PACServer works when system proxy disabled. GeositeUpdater.ResetEvent(); GeositeUpdater.UpdateCompleted += PacServer_PACUpdateCompleted; GeositeUpdater.Error += PacServer_PACUpdateError; _tcpListener?.Stop(); _udpListener?.Stop(); StopPlugins(); // don't put PrivoxyRunner.Start() before pacServer.Stop() // or bind will fail when switching bind address from 0.0.0.0 to 127.0.0.1 // though UseShellExecute is set to true now // http://stackoverflow.com/questions/10235093/socket-doesnt-close-after-application-exits-if-a-launched-process-is-open privoxyRunner.Stop(); try { var strategy = GetCurrentStrategy(); strategy?.ReloadServers(); StartPlugin(); privoxyRunner.Start(_config); TCPRelay tcpRelay = new TCPRelay(this, _config); tcpRelay.OnInbound += UpdateInboundCounter; tcpRelay.OnOutbound += UpdateOutboundCounter; tcpRelay.OnFailed += (o, e) => GetCurrentStrategy()?.SetFailure(e.server); UDPRelay udpRelay = new UDPRelay(this); _tcpListener = new TCPListener(_config, new List <IStreamService> { tcpRelay, _pacServer, new PortForwarder(privoxyRunner.RunningPort), }); _tcpListener.Start(); _udpListener = new UDPListener(_config, new List <IDatagramService> { udpRelay, }); _udpListener.Start(); } catch (Exception e) { // translate Microsoft language into human language // i.e. An attempt was made to access a socket in a way forbidden by its access permissions => Port already in use if (e is SocketException se) { if (se.SocketErrorCode == SocketError.AddressAlreadyInUse) { e = new Exception(I18N.GetString("Port {0} already in use", _config.localPort), e); } else if (se.SocketErrorCode == SocketError.AccessDenied) { e = new Exception(I18N.GetString("Port {0} is reserved by system", _config.localPort), e); } } logger.LogUsefulException(e); ReportError(e); } ConfigChanged?.Invoke(this, new EventArgs()); UpdateSystemProxy(); }