int _tmain(int argc, _TCHAR* argv[]) { char addr[128], cmd[128]; int port; scanf_s("%s", cmd, _countof(cmd)); if (strcmp(cmd, "q") == 0) return 0; if(strcmp(cmd, "r") != 0 && strcmp(cmd, "s") != 0 && strcmp(cmd, "s2") != 0) { printf("unrecognized command"); scanf_s("%s", cmd, _countof(cmd)); return 0; } printf("address & port: "); scanf_s("%s %d", addr, _countof(addr), &port); TCHAR *addrTChar; #ifdef UNICODE WCHAR addrWChar[128]; AnsiToUnicode16(addr, addrWChar, 128); addrTChar = addrWChar; #else addrTChar = addr; #endif if (strcmp(cmd, "r") == 0) TestRecv(addrTChar, port); else if (strcmp(cmd, "s") == 0) TestSend(addrTChar, port); else if (strcmp(cmd, "s2") == 0) TestSend2(addrTChar, port); _getch(); return 0; }
void EventHandler(const NetEventType e, const AFGUID& xClientID, const int nServerID) { std::cout << " event_id: " << e << " thread_id: " << std::this_thread::get_id() << std::endl; if(e == CONNECTED) { bConnected = true; TestSend(); } }