#include "stdafx.h"
#include <winsock2.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
SOCKET SocketDescripter,AcceptSocket; WSADATA wsadataValue;
WORD wData=MAKEWORD(2,2);
WSAStartup(wData,&wsadataValue);
DWORD dvalue;
fd_set *readfds;
SocketDescripter=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(SocketDescripter==SOCKET_ERROR)
{
printf("error");
WSACleanup();
return 0;
}
else
{
printf("\n Sucess\n");
}
sockaddr_in sockap;
sockap.sin_family=AF_INET;
sockap.sin_port=htons(10000);
sockap.sin_addr.s_addr=inet_addr("127.0.0.1");
bind(SocketDescripter,(sockaddr*)&sockap,sizeof(sockap));
listen(SocketDescripter,2);
unsigned long lValue=1;
if(0==ioctlsocket(SocketDescripter, FIONBIO,&lValue))
{
printf("the io control is sucessfully done\n");
}
FD_ZERO(&readfds);
FD_SET(SocketDescripter,&readfds);
dvalue=select(NULL,readfds,NULL,NULL,NULL);
if(FD_ISSET(SocketDescripter,&readfds)==0)
{
int size=sizeof(SocketDescripter);
AcceptSocket=accept(SocketDescripter,(sockaddr*)&SocketDescripter,&size);
char buffer[1024];
printf("i am here");
recv(AcceptSocket,buffer,sizeof(buffer),NULL);
}
return 0;
}
i try like that..
i don't know how to use the select. i studied the msdn website about the basic syntax and try..
can you teach me how to use during a client server application..
i keep on trying that area..
.. please help me..