Async Client Code Flashcards

1
Q

Includes?

A

include <winsock2.h></winsock2.h>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Globals

A

CSOCKET ClientSocket;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Inside WinProc

A

WORD WSAEvent, WSAErr;

//after switch

return(DefWindowProc(hWnd, iMsg, wParam, lParam));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

inside WinProc()

inside

switch (iMsg)

A

case ASYNC_MSG:
{
WSAEvent = WSAGETSELECTEVENT(lParam);
WSAErr = WSAGETSELECTERROR(lParam);
switch (WSAEvent)
{
case FD_READ:
case FD_CONNECT:
case FD_WRITE:
case FD_CLOSE:
default:break;
};
}break;

case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case ID_FILE_CONNECT:
case ID_FILE_DISCONNECT:

default: break;

break;
}break;

case WM_DESTROY:

default:break;
};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

inside

case ASYNC_MSG:

switch (WSAEvent)
case FD_READ:

A

case FD_READ:
{
MessageBox(hWnd, “Read Recieved”,
“Message Inbox”, MB_OK);
Rec = ClientSocket.Recv(ClientSocket.RecvData, 80);
ShowMe(HLB_Output, ClientSocket.RecvData);
break;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

inside

case ASYNC_MSG:

switch (WSAEvent)
case FD_CONNECT:

A

case FD_CONNECT:
{
MessageBox(hWnd, “Connect Recieved”,
“Message Inbox”, MB_OK);
}break;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

inside

case ASYNC_MSG:

switch (WSAEvent)
case FD_WRITE:

A

case FD_WRITE:
{
MessageBox(hWnd, “Write Recieved”,
“Message Inbox”, MB_OK);
ShowMe(HLB_Output, “Successfully connected to server”);
ClientSocket.Send(“Susie Watkins”, 15);
}break;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

inside

case ASYNC_MSG

switch (WSAEvent)
case FD_CLOSE:

A

case FD_CLOSE:
{
MessageBox(hWnd, “Close Recieved”,
“Message Inbox”, MB_OK);
}break;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

inside

case WM_COMMAND:

switch (LOWORD(wParam))
case ID_FILE_CONNECT:

A

case ID_FILE_CONNECT:
{
char ServerIP[20];
char szPort[5];
GetWindowText(HEB_IP, ServerIP, 20);
GetWindowText(HEB_PORT, szPort, 5);
ClientSocket.iPort = atoi(szPort);
int iRet = ClientSocket.Connect(hWnd, TCP,
ServerIP);
}break;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

inside

case WM_COMMAND:

switch (LOWORD(wParam))
case ID_FILE_DISCONNECT:

A

case ID_FILE_DISCONNECT:
{
ClientSocket.Disconnect();
ShowMe(HLB_Output, “Disconnected”);
}break;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

inside

case WM_DESTROY:

A

case WM_DESTROY:
// Cleanup System
// Exit out of Windows
ClientSocket.Disconnect();
PostQuitMessage(0);
break;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly