亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? server.c

?? 《C/C++程序員實用大全》配套代碼 [涉及平臺] VC++ [作者] void [文件大小] 629KB [更新日期] 2005-10-28
?? C
?? 第 1 頁 / 共 2 頁
字號:
     MessageBox (*hWnd, errorBuf, lpBuffer,
                 MB_ICONINFORMATION | MB_OK | MB_APPLMODAL);
     };

                                       // Block until a client connects.
   ConnectNamedPipe(hPipe, NULL);

                                       // Create and init overlap for writing.
   hEventWrt = CreateEvent (NULL, TRUE, FALSE, NULL);
   memset (&OverLapWrt, 0, sizeof(OVERLAPPED));
   OverLapWrt.hEvent = hEventWrt;

                                       // Set the clientIndex, then increment
                                       // the count.  Fill in the structure
                                       // for this client in the array.
   clientIndex = clientCount++;
   clients[clientIndex].hPipe   = hPipe;
   clients[clientIndex].live    = TRUE;
   clients[clientIndex].overLap = OverLapWrt;
   clients[clientIndex].hEvent  = hEventWrt;

                                       // Create and init overlap for reading.
   hEventRd = CreateEvent(NULL,TRUE,FALSE,NULL);
   memset (&OverLapRd, 0, sizeof(OVERLAPPED));
   OverLapRd.hEvent = hEventRd;

                                       // Read from the client, the first
                                       // first message should always be
                                       // the clients user name.
   retCode = ReadFile (hPipe, inBuf, PLEASE_READ, &bytesRead, &OverLapRd);

   if (!retCode)
    lastError = GetLastError();

   if (lastError == ERROR_IO_PENDING)  // Wait on read if need be.
     WaitForSingleObject (hEventRd, (DWORD)-1);

                                       // Put client's name in the array.
   strcpy (clients[clientIndex].Name, inBuf);

                                       // Create a thread which will make
                                       // another server instance of the
                                       // named pipe.
   CreateThread ((LPSECURITY_ATTRIBUTES)NULL,        // No security attributes.
                 (DWORD)0,                           // Use same stack size.
                 (LPTHREAD_START_ROUTINE)ServerProc, // Thread procedure.
                 (LPVOID)hWnd,                       // Parameter to pass.
                 (DWORD)0,                           // Run immediately.
                 (LPDWORD)&ServerThreadID);          // Thread identifier.

   TellAll("");                        // Forces a paint, draws a red spool
                                       // and name for this client.

                                       // Do loop which basically reads from
                                       // this specific client, and then
                                       // uses TellAll() to broadcast the
                                       // message to all the connected
                                       // clients.
   do{
                                       // Read the pipe.
      retCode = ReadFile (hPipe, inBuf, PLEASE_READ, &bytesRead, &OverLapRd);

                                       // Check for three kinds of errors:
                                       // If Error = IO_PENDING, wait til
                                       // the event handle signals success,
                                       // If BROKEN_PIPE, exit the do loop.
                                       // Any other error, flag it to the
                                       // user and exit the do loop.
      if (!retCode)
        {
        lastError = GetLastError();

        switch (lastError)
          {
                                       // IO_PENDING, wait on the event.
           case ERROR_IO_PENDING:
             WaitForSingleObject (hEventRd, (DWORD)-1);
             break;
                                       // Pipe is broken, exit the loop.
           case ERROR_BROKEN_PIPE:
             ExitLoop = TRUE;
             break;
                                       // Something else is wrong, exit the
                                       // the loop after telling the user.
           default:
             LoadString(hInst, IDS_READERROR, lpBuffer, sizeof(lpBuffer));
             wsprintf (errorBuf, lpBuffer, lastError);
             LoadString(hInst, IDS_DEBUGINFO, lpBuffer, sizeof(lpBuffer));
             MessageBox (*hWnd, errorBuf, lpBuffer, MB_OK);
             ExitLoop = TRUE;
             break;
          }
        }

      if (!ExitLoop)
        {
        GetOverlappedResult (hPipe, &OverLapRd, &bytesTransRd, FALSE);

                                       // Use TellAll to broadcast the message.
        if (bytesTransRd)
          TellAll(inBuf);
        else
          TellAll("");
        }

   }while(!ExitLoop);

   clients[clientIndex].live = FALSE;  // Turns spool gray.
   CloseHandle (hPipe);                // Close handles.
   CloseHandle (hEventRd);
   CloseHandle (hEventWrt);
   DisconnectNamedPipe (hPipe);        // Close pipe instance.
   ExitThread(0);                      // Clean up and die.
  }


/*  To write the buffer (input parameter) to all of the clients listed
    in the global array "clients". Clients is a global array which hold information on each client
    connected to the named pipe.  This procedure recieves a buffer.
    It then steps through this global array, and for each client it
    writes the buffer.  */

VOID TellAll( CHAR *buffer )
  {
    DWORD i;                           // Index through array.
    DWORD bytesWritten;                // Used in WriteFile().
    DWORD retCode;                     // Traps return codes.
    CHAR  Buf[LINE_LEN];               // Message Buffer.
    DWORD lastError;                   // Traps returns from GetLastError().

    for(i=0; i < clientCount; i++)     // For all clients in the array.
      {
                                       // If client isn't alive, don't waste
                                       // time writing to it.
      if (clients[i].live)
        {
        retCode = WriteFile (clients[i].hPipe, buffer, strlen(buffer),
                             &bytesWritten, &clients[i].overLap);

                                       // Check 3 kinds of errors: IO_PENDING,
                                       // NO_DATA, or other.  Wait on event
                                       // handle if IO_PENDING, else, if it's
                                       // anything other than NO_DATA (pipe
                                       // client disconnected), flag the user.
                                       // In any case, if it's not IO_PENDING,
                                       // clients[i].live = FALSE, spool turns
                                       // gray.
        if (!retCode)
          {
          lastError = GetLastError();

                                       // IO_PENDING, wait on event handle.
          if (lastError == ERROR_IO_PENDING)
            {
            WaitForSingleObject (clients[i].hEvent, (DWORD)-1);
            }
          else
            {
                                       // If not NO_DATA, flag user.
            if (lastError != ERROR_NO_DATA)
              {
              LoadString(hInst, IDS_DEBUGLAST, lpBuffer, sizeof(lpBuffer));
              wsprintf (Buf, "%s = %d", buffer, GetLastError());
              MessageBox(hWnd, Buf, lpBuffer, MB_OK);
              }
            clients[i].live = FALSE;
            }
          }
        } //if client.live
      } // for loop
                                       // Paint window with new information.
    InvalidateRect(hWnd, NULL, TRUE);
  }



/*
    To draw one of four bitmaps for each client, depending upon the clients
    status (alive = red spool, dead or disconnected = gray), and location in
    the array.  It also draws the clients user name beside the spool.
    This procedure is executed when the WM_PAINT message is trapped.  */

VOID DrawBranch(HDC hDC)
{
                                       // Spool bitmaps.
  HBITMAP hEndLive, hEndDead, hMidLive, hMidDead, hBitMap;

  HDC hDCMem;
  int X, Y;
  BITMAP bm;
  POINT ptSize, ptOrg;
  DWORD index;

                                       // Load bitmaps: two red (live),
                                       // two dead (gray).  End = end
                                       // of tree (last client to connect),
                                       // mid means in the middle somewhere.
       hEndLive = LoadBitmap (hInst, "EndLive");
       hEndDead = LoadBitmap (hInst, "EndDead");

       hMidLive = LoadBitmap (hInst, "MidLive");
       hMidDead = LoadBitmap (hInst, "MidDead");

                                       // For each client, determine if
                                       // if alive or not, and position;
                                       // then blt appropriate map and
                                       // clients name.
    for (index = 0; index < clientCount; index++)
      {

      if (index < clientCount - 1)     // ClientCount - 1 = last (end) client.
       {
        if(clients[index].live)        // If live = red, else = gray.
         hBitMap = hMidLive;
        else
         hBitMap = hMidDead;
       }
      else
       {
        if(clients[index].live)        // If live = red, else = gray.
         hBitMap = hEndLive;
        else
         hBitMap = hEndDead;
       }
                                       // Calculate coordinates:
      X = BITMAP_X;                    // X position is constant.
      Y = index * BITMAP_Y;            // Y is based on index in the array.

                                       // Blt the chosen map.
      hDCMem = CreateCompatibleDC(hDC);
      SelectObject(hDCMem, hBitMap);
      SetMapMode(hDCMem, GetMapMode(hDC));

      GetObject(hBitMap, sizeof(BITMAP), &bm);

      ptSize.x = bm.bmWidth;
      ptSize.y = bm.bmHeight;
      DPtoLP (hDC, &ptSize, 1);

      ptOrg.x = 0;
      ptOrg.y = 0;
      DPtoLP (hDCMem, &ptOrg, 1);

      BitBlt(hDC, X, Y, ptSize.x, ptSize.y,
             hDCMem, ptOrg.x, ptOrg.y, SRCCOPY);


      X =  NAME_X;                     // Relocate X,Y for clients name.
      Y += NAME_Y;
                                       // Write name next to spool.
      TextOut (hDC, X, Y, clients[index].Name, strlen(clients[index].Name));
      DeleteDC(hDCMem);
      }


}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜桃精品在线观看| 久久精品国产精品亚洲红杏| 日韩一级在线观看| 成人97人人超碰人人99| 日本v片在线高清不卡在线观看| 国产欧美一区二区三区沐欲| 欧美日韩日日夜夜| 97国产一区二区| 国内不卡的二区三区中文字幕| 亚洲综合丁香婷婷六月香| 欧美国产视频在线| 日韩一区二区三区四区| 欧美最猛黑人xxxxx猛交| 福利一区二区在线| 九九九精品视频| 午夜精品福利一区二区三区av| 国产精品福利av| 国产女主播视频一区二区| 91精品国产色综合久久不卡蜜臀 | 中文字幕精品一区二区精品绿巨人| 欧美日韩视频在线观看一区二区三区 | 欧美一区二区三区在| 色综合久久中文字幕综合网| 国产成人自拍高清视频在线免费播放| 丝袜亚洲另类丝袜在线| 亚洲国产精品精华液网站| 最新国产成人在线观看| 一区在线播放视频| 久久久久久久久99精品| 日韩欧美国产午夜精品| 在线91免费看| 欧美三级日韩三级国产三级| 欧美主播一区二区三区| 91国模大尺度私拍在线视频| 91偷拍与自偷拍精品| 99riav一区二区三区| 波多野结衣中文字幕一区二区三区| 国产一区二区女| 国产精品456| 国产电影一区二区三区| 国产福利一区在线| 国产成人综合视频| 99re这里都是精品| 日本高清不卡视频| 在线观看一区日韩| 欧美性受xxxx| 欧美日韩国产一二三| 欧美精品电影在线播放| 亚洲视频免费观看| 自拍偷拍国产精品| 一区二区三区国产精华| 亚洲图片有声小说| 日本伊人午夜精品| 国内外成人在线| 成人午夜免费电影| 日本道色综合久久| 欧美日韩国产成人在线免费| 欧美一区二区三区四区视频| 精品欧美乱码久久久久久1区2区| 久久伊99综合婷婷久久伊| 日本一区二区三区视频视频| 国产精品国产a| 亚洲一区二区不卡免费| 偷偷要91色婷婷| 精品一区二区免费| 97久久超碰国产精品电影| 欧美日韩在线不卡| 精品久久久久久久久久久久包黑料| 久久蜜桃av一区二区天堂| 1区2区3区国产精品| 亚洲成av人影院在线观看网| 伦理电影国产精品| www.亚洲人| 欧美精品一二三四| 久久精品人人爽人人爽| 一区二区三区中文字幕在线观看| 日韩av一区二| 99视频在线观看一区三区| 69久久夜色精品国产69蝌蚪网| 26uuu国产在线精品一区二区| 中文字幕中文字幕一区二区| 亚洲国产美国国产综合一区二区| 麻豆91在线观看| www.亚洲免费av| 欧美一级电影网站| 一色屋精品亚洲香蕉网站| 全部av―极品视觉盛宴亚洲| 不卡免费追剧大全电视剧网站| 欧美日韩久久久久久| 中文字幕免费不卡| 蜜桃精品在线观看| 色偷偷久久一区二区三区| 精品少妇一区二区| 亚洲午夜免费视频| 岛国精品在线观看| 欧美一级欧美一级在线播放| 国产一区在线精品| 在线国产亚洲欧美| 亚洲国产高清在线观看视频| 视频一区在线播放| 色综合久久精品| 国产欧美精品一区二区色综合朱莉| 婷婷激情综合网| 91亚洲大成网污www| 久久久久久久久久久久久女国产乱 | 国产一区视频在线看| 欧美日韩国产高清一区| 成人欧美一区二区三区在线播放| 麻豆精品久久精品色综合| 欧美亚洲国产一区在线观看网站| 国产亚洲欧洲一区高清在线观看| 日本在线不卡视频一二三区| 91精品1区2区| 亚洲日穴在线视频| 粉嫩av一区二区三区粉嫩| 精品成a人在线观看| 日韩精品国产精品| 欧美三级蜜桃2在线观看| 成人欧美一区二区三区黑人麻豆| 国产精品911| 欧美精品一区二| 久久99精品久久久久婷婷| 欧美一区二区二区| 香港成人在线视频| 欧美日韩国产一级片| 亚洲图片一区二区| 欧美亚洲综合网| 亚洲一区二区三区不卡国产欧美| 99视频国产精品| 亚洲婷婷在线视频| 99精品欧美一区二区三区小说 | 亚洲精品一区二区三区四区高清| 天天综合色天天综合色h| 欧美日韩视频在线一区二区 | 国产福利一区在线| 久久女同性恋中文字幕| 国产一区二区剧情av在线| 久久这里只精品最新地址| 精品亚洲国内自在自线福利| 欧美成人女星排行榜| 麻豆视频观看网址久久| 日韩欧美国产综合在线一区二区三区| 奇米在线7777在线精品| 日韩欧美国产系列| 国产另类ts人妖一区二区| 久久精品视频免费观看| 懂色av一区二区夜夜嗨| 国产精品久久看| 一本大道久久a久久精品综合 | 精品一区二区在线看| 精品久久一区二区三区| 国产一区二区视频在线播放| 国产亚洲欧美日韩日本| 99久久综合99久久综合网站| 尤物在线观看一区| 欧美人伦禁忌dvd放荡欲情| 免费成人深夜小野草| 久久久精品国产免费观看同学| 成人综合激情网| 亚洲一区二区三区四区在线免费观看 | 成人激情免费网站| 一区二区三区**美女毛片| 7777精品久久久大香线蕉| 久久99精品久久久久久动态图| 久久九九国产精品| 97久久精品人人做人人爽| 丝袜亚洲另类欧美| 日韩精品一区二区三区视频| 成人少妇影院yyyy| 亚洲高清免费观看高清完整版在线观看| 555www色欧美视频| 国产suv精品一区二区三区| 一区二区三区四区视频精品免费| 欧美一区二区福利视频| 成人短视频下载| 天天综合色天天| 国产精品丝袜在线| 在线播放中文一区| av一区二区三区四区| 日本一不卡视频| 中文字幕在线一区二区三区| 91精品久久久久久久99蜜桃| 国产不卡视频在线观看| 亚洲欧美一区二区久久| 精品99久久久久久| 色综合久久久久综合体桃花网| 久久精品国产99久久6| 亚洲乱码日产精品bd| 2023国产精华国产精品| 欧美在线999| 国产99久久久国产精品免费看| 亚洲成a人在线观看| 国产精品美女久久久久久2018 | caoporn国产一区二区| 日韩国产欧美三级| 亚洲女厕所小便bbb| 久久免费视频色| 91精品一区二区三区在线观看| 不卡一区在线观看| 国产精品白丝jk白祙喷水网站|