C++ Winsock Multiclient Server!

Hey guys, i was wondering how can i make my Winsock server multiclient?
Here is my code for my main.cpp:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* This is our Server */

//Includes
#include "Functions.h"

//Main function
int main(){
	DLLVERSION = MAKEWORD(2,1);
	answer = WSAStartup(DLLVERSION, &wsaData);
	sConnect = socket(AF_INET, SOCK_STREAM, NULL);
	addr.sin_addr.s_addr = inet_addr(HostIP);
	addr.sin_family = AF_INET;
	addr.sin_port = htons(PORT);
	sListen = socket(AF_INET, SOCK_STREAM, NULL);
	bind(sListen, (SOCKADDR*)&addr, sizeof(addr));
	listen(sListen, SOMAXCONN);

	//Listening for clients
	for(;;){
		Print("Waiting for incoming connections");
		//If a connection is found
		if(sConnect = accept(sListen, (SOCKADDR*)&addr, &addrlen)){
			Print("Connection found!");
			Send("Hello!");
		}
	}
}


Any help?
If you replace lines 23,24 with a call to create a thread to run the client handler, it'll concurrently handle multiple clients.
Topic archived. No new replies allowed.