mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-05 04:03:49 +01:00
Add Close method to socket manager
This commit is contained in:
1 parent
a1744a6989
commit
b97b0e4cf6
3 files changed
+19
-16
No files matched your search
@@ -42,6 +42,17 @@ InetSocket *SocketManager::CreateSocket(int *index, SocketState state, int domai
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool SocketManager::Close(InetSocket *inetSocket) {
|
||||
_dbg_assert_(inetSocket->state != SocketState::Unused);
|
||||
if (closesocket(inetSocket->sock) != 0) {
|
||||
ERROR_LOG(Log::sceNet, "closesocket(%d) failed", inetSocket->sock);
|
||||
return false;
|
||||
}
|
||||
inetSocket->state = SocketState::Unused;
|
||||
inetSocket->sock = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SocketManager::GetInetSocket(int sock, InetSocket **inetSocket) {
|
||||
std::lock_guard<std::mutex> guard(g_socketMutex);
|
||||
if (sock < MIN_VALID_INET_SOCKET || sock >= ARRAY_SIZE(inetSockets_) || inetSockets_[sock].state == SocketState::Unused) {
|
||||
|
||||
Reference in new issue
Block a user