public ManagerComunicationController(DataReceiverController dataReciv,
                                             DataCacheController dataCache,
                                             FileExportController fileExport,
                                             DataSenderController dataSend,
                                             int port
                                             )

        {
            Console.WriteLine("manager ");
            this.dataReciv  = dataReciv;
            this.dataCache  = dataCache;
            this.fileExport = fileExport;
            this.dataSend   = dataSend;

            this.comManag = new AComunicationManager();

            this.managentList = new List <NetWorkContoroller>();
            // dataReceiveThreadの初期化
            //this.dataReceiveThread = new System.Threading.Thread(this.comManag.dataReceivThreadAction);

            //
            string    ipString = "0.0.0.0";
            IPAddress ipAdd    = IPAddress.Parse(ipString);

            //int port = 6001;

            this.listener_ = new TcpListener(ipAdd, port);
            this.listener_.Start();

            // management受け入れのスレッドの起動
            System.Threading.ThreadPool.QueueUserWorkItem(acceptManagemet);
            System.Threading.ThreadPool.QueueUserWorkItem(dataManagementThreadAction);
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            int serverPort  = 0;
            int managerPort = 0;

            if (args.Length > 0)
            {
                serverPort  = Int32.Parse(args[0]);
                managerPort = Int32.Parse(args[1]);
            }
            /* Debug */
            // server -> server

            /*
             * int connectPort;
             * int recievePort;
             * if (args.Length > 0)
             * {
             *      // サーバプロセス
             *      connectPort = 6501;
             *      recievePort = 6502;
             * }
             * else {
             *      connectPort = -1; // for Client
             *      recievePort = 6501;
             * }
             */
            //int recievePort = 6501;

            Console.WriteLine("server port " + serverPort + " / manager port " + managerPort);
            FileExportController fileCtl = new FileExportController();
            DataCacheController  cache   = new DataCacheController();

            // DataSenderController sender = new DataSenderController(cache, recievePort);
            DataSenderController sender = new DataSenderController(cache, serverPort);

            DataReceiverController receiver = new DataReceiverController(cache, fileCtl, sender);

            //ManagerComunicationController manager = new ManagerComunicationController(receiver,cache,fileCtl,sender, 6901);
            ManagerComunicationController manager = new ManagerComunicationController(receiver, cache, fileCtl, sender, managerPort);

            /* Debug */
            // クライアント用ポートの設定

            /*
             * if (connectPort > 0)
             * {
             *      // 接続先IPポートを設定
             *      manager.startServerComumnication("127.0.0.1", connectPort);
             * }
             * else
             * {
             *      manager.startClietCommunication(6001);
             *
             * }
             */
        }
 public ServerComunicationManager(DataReceiverController receiver, string ip, int port)
 {
     this.isAct    = true;
     this.receiver = receiver;
     for (int i = 0; i < 10; i++)
     {
         try
         {
             Console.WriteLine("conntect to " + ip + ":" + port);
             TcpClient tcp = new TcpClient(ip, port);
             this.tcpClient         = new NetWorkContoroller(tcp);
             this.dataReceiveThread = new System.Threading.Thread(dataReceivThreadAction);
             this.dataReceiveThread.Start();
         }
         catch
         {
             this.isAct = false;
             System.Threading.Thread.Sleep(1000);
             Console.WriteLine("connction filed");
         }
     }
 }
        public ClientComunicationManager(DataReceiverController receiver, int port)
        {
            this.receiver   = receiver;
            this.clientList = new ConcurrentDictionary <int, List <NetWorkContoroller> >();
            this.isAct      = true;

            try
            {
                //
                string    ipString = "0.0.0.0";
                IPAddress ipAdd    = IPAddress.Parse(ipString);
                //int port = 6001;
                Console.WriteLine("Start Client : " + ipString + ":" + port);
                this.listener_ = new TcpListener(ipAdd, port);
                this.listener_.Start();

                System.Threading.ThreadPool.QueueUserWorkItem(acceptTcpConnection);
            }
            catch
            {
                this.isAct = false;
            }
        }