CPPSockets是一个C++编写的网络类库,采用Java的类命名方式和接口,仿造了一个C++版本的,比如ServerSocketDatagramSocketSocketAddress。
示例代码:
int _tmain(int argc, _TCHAR* argv[]){ try{//You can use the browser ( IE, Firefox, etc. ) to visit://https://127.0.0.1/// simple http server ServerSocket s(80);//or//ServerSocket s;//s.bind( SocketAddress("0.0.0.0",80)); printf("listen ok\n");Socket c2("127.0.0.1",80);while(1){ Socket c = s.accept (); printf(" Accept [%d]\n",c.GetSock() ); CloseHandle( CreateThread(0,0,clientthread,&c,0,0) );//fixme}}catch(exception e){printf("%s",e.what());}}
评论