Skip to content

Commit

Permalink
closes #2 agiri.dllは複数のクライアントを受け入れ可能になった
Browse files Browse the repository at this point in the history
  • Loading branch information
castaneai committed Jul 20, 2015
1 parent 6807ce3 commit 5d3954a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions agiri/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ namespace
{
SOCKET listenSocket;

void onAcceptSniffer(const socket_t snifferSock)
DWORD WINAPI onAcceptSnifferThreadFunc(void* argument)
{
auto snifferSock = (reinterpret_cast<const socket_t>(argument));
NinjaConnection conn(snifferSock);
RequestHandler handler(conn);
while (true) {
Expand All @@ -17,6 +18,7 @@ namespace
}
handler.handle(mes);
}
return 0;
}

DWORD WINAPI acceptSnifferThreadFunc(LPVOID)
Expand All @@ -26,8 +28,7 @@ namespace
int snifferAddressLength = sizeof(snifferAddress);
auto acceptedSnifferSock = accept(listenSocket, reinterpret_cast<sockaddr*>(&snifferAddress), &snifferAddressLength);
if (acceptedSnifferSock != INVALID_SOCKET) {
// TODO: accept multi sniffer
onAcceptSniffer(acceptedSnifferSock);
QueueUserWorkItem(onAcceptSnifferThreadFunc, reinterpret_cast<PVOID>(acceptedSnifferSock), 0);
}
}
}
Expand Down

0 comments on commit 5d3954a

Please sign in to comment.