Winsock
OutLine <ul><li>Winsock Introduction </li></ul><ul><li>Project#3 Template </li></ul><ul><li>MFC CSocket </li></ul><ul><li>...
Winsock Introduction (See testMain) <ul><li>int APIENTRY _tWinMain(…) </li></ul><ul><ul><li>main routine </li></ul></ul><u...
Winsock Introduction <ul><li>WSAStartup( … ) </li></ul><ul><ul><li>通知 Windows Sockets  應用程式要開始網路服務 </li></ul></ul><ul><li>...
Events <ul><li>FD_READ:  </li></ul><ul><li>FD_WRITE:  </li></ul><ul><li>FD_CONNECT:  </li></ul><ul><li>FD_ACCEPT:  </li></...
Project#3 Template <ul><li>EditPrintf (HWND hwndEdit, TCHAR * szFormat, ...) </li></ul><ul><ul><li>EditPrintf(hwndEdit, TE...
To Do <ul><li>Fill actions when event happen </li></ul><ul><li>When FD_READ/FD_WRITE happen ? </li></ul><ul><ul><li>GET ac...
MFC CSocket <ul><li>繼承 CSocket 類別 </li></ul><ul><li>覆寫 OnAccept  等 function </li></ul>
 
 
Demo hint <ul><li>可以用作業二的任一 Server, 但不能重開 </li></ul><ul><li>有把握的話 ,Test_case 1&2 可以一起測 </li></ul><ul><li>Delayed server co...
Upcoming SlideShare
Loading in …5
×

Winsock

577
-1

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
577
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Winsock

  1. 1. Winsock
  2. 2. OutLine <ul><li>Winsock Introduction </li></ul><ul><li>Project#3 Template </li></ul><ul><li>MFC CSocket </li></ul><ul><li>Demo hint </li></ul>
  3. 3. Winsock Introduction (See testMain) <ul><li>int APIENTRY _tWinMain(…) </li></ul><ul><ul><li>main routine </li></ul></ul><ul><ul><li>make hInstance maps to WndProc </li></ul></ul><ul><ul><li>while loop for wait message </li></ul></ul><ul><li>BOOL InitInstance(HINSTANCE , int) </li></ul><ul><ul><li>CreateWindow </li></ul></ul><ul><ul><li>Show Window </li></ul></ul><ul><li>LRESULT CALLBACK WndProc( …) </li></ul><ul><ul><li>Handle message </li></ul></ul>
  4. 4. Winsock Introduction <ul><li>WSAStartup( … ) </li></ul><ul><ul><li>通知 Windows Sockets 應用程式要開始網路服務 </li></ul></ul><ul><li>WSAAsyncSelect (…) </li></ul><ul><li>WSACleanup() </li></ul><ul><ul><li>結束 Windows Sockets 的使用 </li></ul></ul><ul><li>WSAGETSELECTEVENT(lParam) </li></ul><ul><ul><li>extract the event code from the lParam in the response to a WSAAsyncSelect() </li></ul></ul><ul><ul><li>LOWORD(lParam) </li></ul></ul>
  5. 5. Events <ul><li>FD_READ: </li></ul><ul><li>FD_WRITE: </li></ul><ul><li>FD_CONNECT: </li></ul><ul><li>FD_ACCEPT: </li></ul><ul><li>FD_CLOSE: </li></ul>
  6. 6. Project#3 Template <ul><li>EditPrintf (HWND hwndEdit, TCHAR * szFormat, ...) </li></ul><ul><ul><li>EditPrintf(hwndEdit, TEXT(&quot;=== Server START === &quot;)); </li></ul></ul><ul><ul><li>EditPrintf(hwndEdit, TEXT(&quot;=== Accept one new client(%d), List size:%d === &quot;), ssock, Socks.size()); </li></ul></ul><ul><li>case ID_LISTEN: </li></ul><ul><ul><li>Press the “Listen” button </li></ul></ul><ul><ul><li>The button’s ID is “ ID_LISTEN ” </li></ul></ul><ul><li>WM_USER => 0x0400 </li></ul><ul><ul><li>All Message Numbers below 0x0400 are RESERVED. </li></ul></ul>
  7. 7. To Do <ul><li>Fill actions when event happen </li></ul><ul><li>When FD_READ/FD_WRITE happen ? </li></ul><ul><ul><li>GET action </li></ul></ul><ul><ul><li>Target Server I/O </li></ul></ul><ul><ul><li>Handle them same place ? </li></ul></ul><ul><li>Handle htm & cgi </li></ul>
  8. 8. MFC CSocket <ul><li>繼承 CSocket 類別 </li></ul><ul><li>覆寫 OnAccept 等 function </li></ul>
  9. 11. Demo hint <ul><li>可以用作業二的任一 Server, 但不能重開 </li></ul><ul><li>有把握的話 ,Test_case 1&2 可以一起測 </li></ul><ul><li>Delayed server code 和 hide testcase 會在 demo 前幾天公怖 </li></ul><ul><li>Timeout 機制請做成選項 還要說明如何做 </li></ul>

×