   umm a problem with winsock
  hello all... i'm here again :P.i have a problom with the SELECT() stuff.... i tried to write a program but when i run it ... it just getting closed and i get the XP window that said the program had errors and it had to be shutted down or somthing...here is the code of my program:#pragma comment(lib, "WS2_32.lib")#include <winsock.h>#include <stdio.h>#include <time.h>#define NETWORK_ERROR -1#define NETWORK_OK0int main(){SOCKET theClient;char buffer[256];fd_set working;WORD sockVersion;WSADATA wsaData;struct timeval tv;    fd_set readfds;    tv.tv_sec = 2;    tv.tv_usec = 500000;int nret;sockVersion = MAKEWORD(1, 1);// We'd like Winsock version 1.1// We begin by initializing WinsockWSAStartup(sockVersion, &wsaData);// Next, create the listening socketSOCKET listeningSocket;listeningSocket = socket(AF_INET,// Go over TCP/IP    SOCK_STREAM,   // This is a stream-oriented socket IPPROTO_TCP);// Use TCP rather than UDP// Use a SOCKADDR_IN struct to fill in address informationSOCKADDR_IN serverInfo;serverInfo.sin_family = AF_INET;serverInfo.sin_addr.s_addr = INADDR_ANY;// Since this socket is listening for connections,// any local address will doserverInfo.sin_port = htons(8888);// Convert integer 8888 to network-byte order// and insert into the port field// Bind the socket to our local server addressnret = bind(listeningSocket, (LPSOCKADDR)&serverInfo, sizeof(struct sockaddr));// Make the socket listennret = listen(listeningSocket, 10);// Up to 10 connections may wait at any// one time to be accept()'ed// Wait for a clientint i;while (100>3){if( -1 != select(NULL, &readfds, NULL, NULL, &tv) ){ if( FD_ISSET( listeningSocket, &working ) ){theClient = accept(listeningSocket,   NULL,// Address of a sockaddr structure (see explanation below)   NULL);// Address of a variable containing size of sockaddr structFD_SET(theClient, &working); }}for (i=0;i<10;i++){  if( FD_ISSET( i, &working ) ){nret = recv(theClient,    buffer,    256,// Complete size of buffer    0);printf("reaciving a massage: \n");puts(buffer);printf("\n");  }}  }// Send and receive from the client, and finally,closesocket(theClient);closesocket(listeningSocket);// Shutdown WinsockWSACleanup();return NETWORK_OK;}any idea what is the problem?thanks in advance   
  You don't ever actually add any sockets to the set, or zero it out. You need to use FD_ZERO(&readfd); to zero it out, then FD_SET() to set a socket in the set (It's been a while since I used it, I can't remember the syntaxy offhand, but the MSDN knows.Also - you should learn to use the debugger, there's a great Article on GDNet by superpig about it.   ;  Well I've just had a quick look at your code and the one thing I will say is you need to check the return values of functions as to find if there were any errors. As a side note when using select you should use the "select" function to see if there are any errors on sockets instead of WSA_lasterror() (or whatever the win32 func is).   ;  There's a whole bunch wrong with that (using the master set in select, using the set you didn't use in select for ISSET, checking 1->10 for the sockets when you're on windows [and thus sockets will be arbitrary], complicating things with a timeout but not checking for it...), but mostly in the comprehension of what is going on. The structure though is fine. I am sorry I don't have the time to do discuss things further at the moment, tomarrow if you're still having troubles.