Example #1
0
        private void StartNetworkListener()
        {
            Log.Info("Starting TCP Listener");
            try
            {
                string ip = Common.LocalIPAddress();
                NetworkComms.AppendGlobalIncomingPacketHandler <string>("Plugin", PluginMessageReceived);
                NetworkComms.AppendGlobalIncomingPacketHandler <string>("Method", MethodMessageReceived);
                //Start listening for incoming connections
                TCPConnection.StartListening(new IPEndPoint(IPAddress.Parse(ip), 10051));
                //TCPConnection.StartListening(true);

                foreach (System.Net.IPEndPoint localEndPoint in TCPConnection.ExistingLocalListenEndPoints())
                {
                    Log.Info("Service listening for TCP connection on: " + localEndPoint.Address + ":" + localEndPoint.Port);
                }
            }
            catch (Exception ex)
            { Log.Error("Error starting TCP Listener: " + ex.Message, ex); }
        }
Example #2
0
        public override void Get_ChargeDensity(ILayer[] layers, ref SpinResolved_Data density, Band_Data chem_pot)
        {
            // send data to client
            NetworkComms.SendObject("layers", clientIP, clientPort, layers);
            NetworkComms.SendObject("density", clientIP, clientPort, density);
            NetworkComms.SendObject("chem_pot", clientIP, clientPort, chem_pot);

            // Call the save_density routine
            //NetworkComms.AppendGlobalIncomingPacketHandler<SpinResolved_Data>("new_density", Save_Density);

            //Start listening for incoming connections
            TCPConnection.StartListening(true);

            //Print out the IPs and ports we are now listening on
            Console.WriteLine("Server listening for TCP connection on:");
            foreach (System.Net.IPEndPoint localEndPoint in TCPConnection.ExistingLocalListenEndPoints())
            {
                Console.WriteLine("{0}:{1}", localEndPoint.Address, localEndPoint.Port);
            }

            throw new NotImplementedException();
        }