// クライアント接続待ちスレッド private void ServerThread() { try { int intNo; while (true) { // ソケット接続待ち TcpClient myTcpClient = myListener.AcceptTcpClient(); // クライアントから接続有り for (intNo = 0; intNo <= myClient.GetLength(0) - 1; intNo++) { if (myClient[intNo] == null) { break; } else if (myClient[intNo].objSck.Connected == false) { break; } } if (intNo < myClient.GetLength(0)) { // クライアント送受信オブジェクト生成 myClient[intNo] = new ClientTcpIp(); myClient[intNo].intNo = intNo + 1; myClient[intNo].objSck = myTcpClient; myClient[intNo].objStm = myTcpClient.GetStream(); // クライアントとの送受信開始 Thread myClientThread = new Thread( new ThreadStart(myClient[intNo].ReadWrite)); myClientThread.Start(); } else { // 接続拒否 myTcpClient.Close(); } } } catch { } }
// クライアント接続待ちスレッド private void ServerThread() { try { int intNo; while (true) { // ソケット接続待ち TcpClient myTcpClient = myListener.AcceptTcpClient(); // クライアントから接続有り for (intNo = 0; intNo <= myClient.GetLength(0) - 1; intNo++) { if (myClient[intNo] == null) { break; } else if (myClient[intNo].objSck.Connected == false) { break; } //else { //接続されていたら // if (myClient[intNo] != null) // { // if (myClient[intNo].rcvflg == true) // { //受信フラグクリア // myClient[intNo].rcvflg = false; // if (Rcvflg != true) // { // RcvData = myClient[intNo].rcvdat; // Rcvflg = true; // } // } //} } if (intNo < myClient.GetLength(0)) { // クライアント送受信オブジェクト生成 myClient[intNo] = new ClientTcpIp(); myClient[intNo].intNo = intNo + 1; myClient[intNo].objSck = myTcpClient; myClient[intNo].objStm = myTcpClient.GetStream(); // クライアントとの送受信開始 Thread myClientThread = new Thread( new ThreadStart(myClient[intNo].ReadWrite)); myClientThread.Start(); Lnkflg = true; myClient[intNo].Lnkflg = true; } else { // 接続拒否 myTcpClient.Close(); } } } catch { } }