Hello, i've tried to use Windows sockets not in my LAN and i've noticed that every time my program starts it gets CPU overflowed weirdly
ProgramConfig myConfig = ExecuteServerConfig("config.ini");
WSAData wData;
if(WSAStartup(MAKEWORD(2,2),&wData) == -1)return 0;
sockaddr_in serveraddr;
int sock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
serveraddr.sin_port = htons(myConfig.Port);
serveraddr.sin_addr.s_addr = inet_addr(myConfig.Server);
serveraddr.sin_family = AF_INET;
bind(sock,(sockaddr*)&serveraddr,sizeof(serveraddr));
listen(sock,1);
sockaddr_in clientaddr;
int size = sizeof(clientaddr);
while(1)
{
int csocket = accept(sock,(sockaddr*)&clientaddr,&size);
int byteswritten;
char buffer[256];
while(recv(csocket,buffer,sizeof(buffer),0) != -1)
{
CommandHandler(buffer);
free(buffer);
}
}
my client socket is always the same client with the same ip, that connects without stopping even when i'm changing port in my config file.
what is this weird thing?