這是網上下的**,體現了select的使用
dword winapi connect_thread(lpvoid lpparam)
fd_set fdrecv;
fd_set fdsend;
timeval seltime;
int irecv=0;
int isend=0;
carrayarraysendbuffer;
critical_section cs_array;
initializecriticalsection(&cs_array);
bool isconnect=true;
while(isconnect)
else if(ret==0)
continue;
if(fd_isset(sock,&fdrecv))
int nleft=0;
while(ret>0) //處理粘包
}if(fd_isset(sock,&fdsend)&&arraysendbuffer.getsize()>0)
closesocket(sock);
return 0;
}
vxworks下select 的使用
select 作用是掛起一系列的檔案描述符,其api為 int select int width,number of bits to examine from 0 fd set preadfds,read fds fd set pwritefds,write fds fd set pexceptfd...
select模式下的tcp伺服器
但是每次和客戶端交流時都只能交流2,3次就斷了,不知道什麼原因 include include include include pragma comment lib,ws2 32.lib using namespace std int main int nport 5150 建立監聽套接字 sock...
linux下select函式的使用
先看下列的例子程式 include include include include define stdin 0 define true 1 define false 0 define ulong unsigned long static struct timeval timelast static...