Original Post
im setting up a dos program to be the server for a game im working on, and i want to use nonblocking mode and not use windows messages to notify me of writing/reading access to the sockets because i plan to port it to linux later down the road
alright, so everything else works fine, but within the infinite while loop, i have:
for(int i = 1; i <= 10; i++){
//do some code
}
and the for loop doesn''t execute the code at all....its like it''s ignoring every single for loop in the program, but doing evetything else fine....i was wondering if this is maybe because of nonblocking not being totally set up right? and its blocking and not causing my loops to execute? thats the only thing i can think of...heres how im setting nonblocking mode for my listen socket:
unsigned long Options = 1;
ioctlsocket(ListenSock, FIONBIO, &Options);
this is called right after i create the socket using socket()....after them calls i then bind() and listen() and go through the infinite while loop and it works fine for accepting new connections
this is in the infinite loop btw)
FD_SET(ListenSock, &RecvFDS);
select(0, &RecvFDS, &SendFDS, &ErrorFDS, &TVal);
if(FD_ISSET(ListenSock, &RecvFDS)){
OpenSock = GetOpenSock();
FD_CLR(Socks[OpenSock].Socket, &Socks[OpenSock].RecvFDS);
FD_CLR(Socks[OpenSock].Socket, &Socks[OpenSock].SendFDS);
Socks[OpenSock].SINLen = sizeof(sockaddr_in);
Socks[OpenSock].Socket = accept(ListenSock, (struct sockaddr*)&Socks[OpenSock].SIN, &Socks[OpenSock].SINLen);
ioctlsocket(Socks[OpenSock].Socket, FIONBIO, &Options);
FD_SET(Socks[OpenSock].Socket, &Socks[OpenSock].RecvFDS);
FD_SET(Socks[OpenSock].Socket, &Socks[OpenSock].SendFDS);
Socks[OpenSock].Active = TRUE;
printf("Accepted: %i\n", OpenSock);
}
then it loops through all the active sockets using a for loop, if they are active it checks them for data to write/read, but the loop isn''t being preformed...i use the same checking process for the listensock as all the other client sockets
i hope this is enough information for someone to help me with...or maybe a few of u have had this same problem
thanx