#include "SocketS.h" //#include "cst.h" #include struct clienMsg { int myName; int snedName; int code; int len; char buf[1024]; }; struct MsgHead { int MyIndex = 0; int SendIndex = 0; int bufLen = 0; time_t tm = 0; //char token[34] = { 0 }; }; struct msgInfo { int buflen = 0; char buf[10240] = { 0 }; }; std::map clienMap; std::map clienIndex; SocketS s(1); int cont = 0; VOID closeFunc(int index) { if (clienIndex.find(index) != clienIndex.end()) { clienMap.erase(clienIndex[index]); clienIndex.erase(index); } } VOID recvFunc(int index, char* buf, int len) { //s.CloseClien(index); //cout << buf; string str = buf; s.SendStr(index, str); } int main(void) { //s.SetRecvFunc([&tt](SocketS::msgInfo info) {return tt.ppp(info); }); //s.Creat(6666); //s.Close(); s.SetCloseFunc(closeFunc); s.SetRecvFunc(recvFunc); if (s.Creat(6666)) { cout << "服务器创建成功\n"; } else { cout << "服务器创建失败\n"; } while(1) { Sleep(100); } return 0; }