Hey guys, well, I started over with my WinSock functions, and it's going tons better then it did before... So I had a question. I start up Winsock. I create a socket, I bind it, I listen on it. Now, after I start the listening socket, I go into a Do loop, and accept clients... Heres the loop which I'm having troubles with.
do{
clientS = accept(listenS, NULL, NULL);
/*if (WM_DESTROY == 1){
closesocket(listenS);
WSACleanup();
PostQuitMessage (0); // exit
} */
Sleep(250); // PROGRAM HANGS IN THIS LOOP, IT STOPS RESPONDING... AND I TRIED THE IF WM_DESTROY :(
}while (clientS == INVALID_SOCKET); Ok, for one, I want to wait for a client in a loop and STILL check to see if WM_DESTROY command has been sent.... As you can see, I commented out the part that I tried to check if WM_DESTROY was initiated. Any suggestions on that?
Now, I have this code:
char IpMem[40];
char sPort[10];
GetWindowText(hPortData, sPort, sizeof(sPort));
char sIp[30];
int iIp, iPort;
GetWindowText(hIPData, sIp, sizeof(sIp));
strcat(IpMem, sIp);
strcat(IpMem, ":");
strcat(IpMem, sPort);
MessageBox(NULL, IpMem, "Ip and Port", MB_OK);
iIp = atoi(sIp);
iPort = atoi(sPort);
listenS = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (listenS == INVALID_SOCKET)
{
WSACleanup();
closesocket(listenS);
MessageBox(NULL, "Failed to create socket, SweetTalk will automatically exit now.", "Error", MB_ICONEXCLAMATION | MB_OK);
return EXIT_SUCCESS;
}
SOCKADDR_IN info;
info.sin_family = AF_INET;
info.sin_addr.s_addr = INADDR_ANY; // should I replace INADDR_ANY with iIp?
info.sin_port = htons(8888); // should I replace 8888 with iPort?
ret = bind(listenS,(LPSOCKADDR)&info,sizeof(struct sockaddr));
if (ret == SOCKET_ERROR)
{
WSACleanup();
closesocket(listenS);
MessageBox(NULL, "Failed to bind socket, SweetTalk will automatically exit now.", "Error", MB_ICONEXCLAMATION | MB_OK);
return EXIT_SUCCESS;
} And there you can see my comments, which are my questions...
Should I replace "INADDR_ANY" with iIp? And should I replace "htons(8888)" with iPort?
If you need any more info on what I need help with, please ask...
Thanks a ton times a million
