








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









Small WinSock application example
A WHOIS client with the following functions
whose name is hard-coded in the application
edit control
Application User Interface
application example
application example
application example
application example
case IDC_BUTTON_SEND:
EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_SEND), FALSE); // disable for 2nd use GetDlgItemText(hDlg, IDC_EDIT_DOMAIN, (LPSTR)domainName, MAX_DOMAIN_LEN+1); strcpy(domainName+strlen(domainName), "\r\n"); if(send(clientSocket, (const char *)domainName, strlen(domainName), 0) == SOCKET_ERROR) EndDialog(hDlg, 1); else { bytesReceived = recv(clientSocket, startOfBuffer, BUFFER_SIZE-1, 0); // - for NULL while(bytesReceived > 0) // 0:close SOCKET_ERROR:error { startOfBuffer += bytesReceived; // move it forward bytesReceived = recv(clientSocket, startOfBuffer, BUFFER_SIZE-(startOfBuffer-result)-1, 0); // -1 for NULL }
application example
if(startOfBuffer != result) // something received *startOfBuffer = NULL; // NULL terminate else strcpy(result, "Null Response");
SetDlgItemText(hDlg, IDC_EDIT_RESULT, result); } break;
case IDCANCEL: EndDialog(hDlg, 0); break; } return TRUE; break;
default: return FALSE; } return TRUE;
}
application example