I'm attempting to build a simple listener, preferably without a Thread, but I am lost.
I have a working listener in 'console' mode but I need one that works with MFC. It should stay open indefinately - (until I send a shutdown message)
This is my initial non-working attempt. It connects and listens OK, but the Accept() function only receives the first line sent and then freezes. (using the code as shown - while and do loops edited out)
CString clientIP = "xxx.xxx.xxx.xxx";
CSocket hsock;
hsock.Create(port,SOCK_STREAM,clientIP);
hsock.Listen(5);
char buf[512];
// I know this is NOT correct, but I cannot figure out hwo to make it work
//while (1) {
CSocket tsock;
hsock.Accept(tsock);
int bytes = hsock.Receive(buf,sizeof(buf),0);
// do {
AfxMessageBox(buf);
// }
//}
I've read thought Micro$ confusing MFC documentation on Socket, CSocket, AsyncSocket and I come away more confused that when I started. I think I need to use Archive(), but again I get lost.
Any help would be very welcome, but please, no links to the Micro$ site.