Beispiel #1
0
        static void Main(string[] args)
        {
            // Send anonymous statistics about the usage of Pcap.Net
            PcapDotNet.Analysis.PcapDotNetAnalysis.OptIn = true;

            // Retrieve the device list from the local machine
            IList<LivePacketDevice> allDevices = LivePacketDevice.AllLocalMachine;

            if (allDevices.Count == 0)
            {
                Console.WriteLine("No interfaces found! Make sure WinPcap is installed.");
                return;
            }

            // Print the list
            for (int i = 0; i != allDevices.Count; ++i)
            {
                LivePacketDevice device = allDevices[i];
                Console.Write((i + 1) + ". " + device.Name);
                if (device.Description != null)
                    Console.WriteLine(" (" + device.Description + ")");
                else
                    Console.WriteLine(" (No description available)");
            }

            int deviceIndex = 0;
            do
            {
                Console.WriteLine("Enter the interface number (1-" + allDevices.Count + "):");
                string deviceIndexString = Console.ReadLine();
                if (!int.TryParse(deviceIndexString, out deviceIndex) ||
                    deviceIndex < 1 || deviceIndex > allDevices.Count)
                {
                    deviceIndex = 0;
                }
            } while (deviceIndex == 0);

            // Take the selected adapter
            PacketDevice selectedDevice = allDevices[deviceIndex - 1];

            rayclient = new SynchronousSocketListener(11000);

            // Send test data to the remote device.
            //rayclient.raysend("This is a test<EOF>");

            rayBuilder = new StringBuilder();
            // Open the device
            using (PacketCommunicator communicator =
                selectedDevice.Open(65536,                                  // portion of the packet to capture
                                                                            // 65536 guarantees that the whole packet will be captured on all the link layers
                                    PacketDeviceOpenAttributes.Promiscuous, // promiscuous mode
                                    1000))                                  // read timeout
            {
                Console.WriteLine("Listening on " + selectedDevice.Description + "...");

                // start the capture
                communicator.ReceivePackets(0, PacketHandler);
            }
        }
Beispiel #2
0
    public static void Main()
    {
        SynchronousSocketListener server = new SynchronousSocketListener(11000);

        server.listeners = new ConnectionListener(onConnection);

        server.listen(10);

        Console.WriteLine("\nPress ENTER to continue...");
        Console.Read();
    }
Beispiel #3
0
    public static void Main()
    {
        SynchronousSocketListener server = new SynchronousSocketListener(11000);

        server.listeners = new ConnectionListener(onConnection);

        server.listen(10);

        Console.WriteLine("\nPress ENTER to continue...");
        Console.Read();
    }
Beispiel #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            //services.AddControllersWithViews();

            services.AddMemoryCache((m) =>
            {
            });

            services.Configure <IISServerOptions>(options =>
            {
                options.AutomaticAuthentication = false;
            });

            services.AddWebSockets((options) =>
            {
            });

            var configurationBL = new ConfigurationBL(Configuration);

            GlobalSettings.WebSocketPort    = configurationBL.WebSocketPort;
            GlobalSettings.SemaphoreInitial = configurationBL.SemaphoreInitial;
            GlobalSettings.DefaultCacheExpirationSeconds = configurationBL.DefaultCacheExpirationSeconds;
            GlobalSettings.AutoPopulateEndpoints         = configurationBL.AutoPopulateEndpoints;
            GlobalSettings.PersistCacheToFile            = configurationBL.PersistCacheToFile;
            GlobalSettings.PersistentDataFileName        = configurationBL.PersistentDataFileName;

            var t = new System.Threading.Thread(() =>
            {
                SynchronousSocketListener.StartListening();
            })
            {
                IsBackground = true
            };

            t.Start();

            //services.AddMvc(option =>
            // {
            //     option.OutputFormatters.Clear();
            //     option.OutputFormatters.Add(new Utf8JsonOutputFormatter(StandardResolver.Default));
            //     option.InputFormatters.Clear();
            //     option.InputFormatters.Add(new Utf8JsonInputFormatter());
            // });
        }
        public static void Start(int port)
        {
            try
            {
                SynchronousSocketListener listener = new SynchronousSocketListener
                {
                    HandleRequest = Listener.HandleRequest
                };

                listener.StartListening(port);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                return;
            }
        }
Beispiel #6
0
        public static void Start()
        {
            ManualResetEvent exchangeOpen     = new ManualResetEvent(false);
            ManualResetEvent processSignaller = new ManualResetEvent(false);
            BizDomain        equityDomain;

            equityDomain = new BizDomain("Salt Futures", new string[] { "RSXH", "RSXM", "RSXU", "RSXZ" });

            equityDomain.OrderBook.OrderPriority = new PriceTimePriority();

            EquityMatchingLogic equityMatchingLogic = new EquityMatchingLogic(equityDomain);

            equityDomain.Start();

            //starts listening for orders
            Task.Factory.StartNew(() => SynchronousSocketListener.StartListening(equityDomain));


            while (true)
            {
                if (DateTime.Now > startTime + stagingTime)
                {
                    //equityDomain.findOpenPrice();
                    open = true;
                    break;
                }
                else
                {
                    exchangeOpen.WaitOne(10);
                }
            }


            Console.WriteLine("Press any key to stop");
            Console.ReadLine();

            return;
        }
        //Mutex syncExchange = new Mutex(false, "SyncExchange");
        //[STAThread]
        public static void Start()
        {
            LeafContainer.openPriceFound.Set();
            EquityMatchingEngine.OMEHost.open    = false;
            EquityMatchingEngine.OMEHost.running = true;

            EquityMatchingEngine.OMEHost.startTime = DateTime.Now;
            ManualResetEvent exchangeOpen     = new ManualResetEvent(false);
            ManualResetEvent processSignaller = new ManualResetEvent(false);
            BizDomain        equityDomain;

            equityDomain = new BizDomain("Salt Futures", new string[] { "RSXH", "RSXM", "RSXU", "RSXZ" });

            equityDomain.OrderBook.OrderPriority = new PriceTimePriority();

            EquityMatchingLogic equityMatchingLogic = new EquityMatchingLogic(equityDomain);

            equityDomain.Start();

            //starts listening for orders
            Task.Factory.StartNew(() => SynchronousSocketListener.StartListening(equityDomain));


            while (true)
            {
                if (DateTime.Now > startTime + stagingTime)
                {
                    //equityDomain.findOpenPrice();
                    open = true;
                    break;
                }
                else
                {
                    exchangeOpen.WaitOne(10);
                }
            }
        }
Beispiel #8
0
 public static int Main(String[] args)
 {
     SynchronousSocketListener.StartListening();
     //SynchronousSocketClient.StartClient();
     return(0);
 }
Beispiel #9
0
 static int Main(string[] args)
 {
     Console.WriteLine("I am the Server.");
     SynchronousSocketListener.StartListening();
     return(0);
 }
        protected void StartServer_Click(object sender, EventArgs e)
        {
            SynchronousSocketListener ssl = new SynchronousSocketListener();

            ssl.StartListening();
        }
Beispiel #11
0
 static void Main(string[] args)
 {
     SynchronousSocketListener.StartListening();
 }
Beispiel #12
0
 static int Main(string[] args)
 {
     SynchronousSocketListener.StartListening();
     return(0);
 }
Beispiel #13
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            webBrowser1.Width  = this.Width - 17;
            webBrowser1.Height = this.Height - 100;
            textBox1.Width     = this.Width - 100;
            btn_go.Location    = new Point(this.Width - btn_go.Width - 25, btn_go.Location.Y);
            webBrowser1.ScriptErrorsSuppressed = true;
            BackgroundWorker bw = new BackgroundWorker();

            // this allows our worker to report progress during work
            // bw.WorkerReportsProgress = true;

            // what to do in the background thread
            bw.DoWork += new DoWorkEventHandler(
                delegate(object o, DoWorkEventArgs args)
            {
                while (true)
                {
                    //BackgroundWorker b = o as BackgroundWorker;
                    SynchronousSocketListener.StartListening();
                    string returned = SynchronousSocketListener.data;
                    switch (returned.Substring(0, 2))
                    {
                    case "up":
                        //case "u-":
                        System.Windows.Forms.SendKeys.SendWait("{PGUP}");
                        break;

                    case "do":
                        //case "d-":
                        System.Windows.Forms.SendKeys.SendWait("{PGDN}");
                        break;

                    case "ri":
                        webBrowser1.GoForward();
                        //MessageBox.Show("forward");
                        break;

                    case "le":
                        webBrowser1.GoBack();
                        //MessageBox.Show("back");
                        break;

                    case "se":
                        string filter = returned.Substring(3);
                        filter        = filter.Replace(' ', '+');
                        webBrowser1.Navigate("https://www.google.com.eg/search?q=" + filter);
                        textBox1.Text = "https://www.google.com.eg/search?q=" + filter;
                        break;

                    case "ma":
                        webBrowser1.Navigate("file:///C:/Users/el-mostafa.org/Desktop/QingLong/InteractBrowser/InteractBrowser/maps2.html");
                        textBox1.Text = "file:///C:/Users/el-mostafa.org/Desktop/QingLong/InteractBrowser/InteractBrowser/maps2.html";
                        break;

                    case "ft":
                        webBrowser1.Navigate("file:///C:/Users/el-mostafa.org/Desktop/QingLong/InteractBrowser/InteractBrowser/maps2.html?r=" + returned.Substring(3));
                        textBox1.Text = "file:///C:/Users/el-mostafa.org/Desktop/QingLong/InteractBrowser/InteractBrowser/maps2.html?r=" + returned.Substring(3);
                        break;
                    }
                }
            });
            bw.RunWorkerAsync();
            webBrowser1.Navigate("http://www.google.com");
            textBox1.Text = "http://www.google.com";
        }