mirror of
https://github.com/CraftyBoss/SuperMarioOdysseyOnline.git
synced 2024-11-25 12:45:17 +00:00
Add socket errno display
This commit is contained in:
parent
41746805c2
commit
b25cad8812
4 changed files with 12 additions and 0 deletions
|
@ -22,6 +22,7 @@ class SocketBase {
|
||||||
bool closeSocket();
|
bool closeSocket();
|
||||||
|
|
||||||
void setName(const char *name) {strcpy(sockName, name);};
|
void setName(const char *name) {strcpy(sockName, name);};
|
||||||
|
u32 socket_errno;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
s32 socket_log(const char* str);
|
s32 socket_log(const char* str);
|
||||||
|
|
|
@ -34,4 +34,6 @@ s32 Recv(s32 socket, void* out, ulong outLen, s32 flags);
|
||||||
u16 InetHtons(u16 val);
|
u16 InetHtons(u16 val);
|
||||||
s32 InetAton(const char* addressStr, in_addr* addressOut);
|
s32 InetAton(const char* addressStr, in_addr* addressOut);
|
||||||
|
|
||||||
|
u32 GetLastErrno();
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
|
@ -89,6 +89,7 @@ void drawMainHook(HakoniwaSequence *curSequence, sead::Viewport *viewport, sead:
|
||||||
gTextWriter->setScaleFromFontHeight(20.f);
|
gTextWriter->setScaleFromFontHeight(20.f);
|
||||||
|
|
||||||
gTextWriter->printf("Client Socket Connection Status: %s\n", Client::sInstance->mSocket->getStateChar());
|
gTextWriter->printf("Client Socket Connection Status: %s\n", Client::sInstance->mSocket->getStateChar());
|
||||||
|
gTextWriter->printf("nn::socket::GetLastErrno: 0x%x\n", Client::sInstance->mSocket->socket_errno);
|
||||||
gTextWriter->printf("Packet Queue Length: %d\n", Client::sInstance->mSocket->mPacketQueue.size());
|
gTextWriter->printf("Packet Queue Length: %d\n", Client::sInstance->mSocket->mPacketQueue.size());
|
||||||
gTextWriter->printf("Total Connected Players: %d\n", Client::getConnectCount() + 1);
|
gTextWriter->printf("Total Connected Players: %d\n", Client::getConnectCount() + 1);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ nn::Result SocketClient::init(const char* ip, u16 port) {
|
||||||
if (!nn::nifm::IsNetworkAvailable()) {
|
if (!nn::nifm::IsNetworkAvailable()) {
|
||||||
Logger::log("Network Unavailable.\n");
|
Logger::log("Network Unavailable.\n");
|
||||||
this->socket_log_state = SOCKET_LOG_UNAVAILABLE;
|
this->socket_log_state = SOCKET_LOG_UNAVAILABLE;
|
||||||
|
this->socket_errno = nn::socket::GetLastErrno();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,6 +39,7 @@ nn::Result SocketClient::init(const char* ip, u16 port) {
|
||||||
|
|
||||||
Logger::log("Socket Unavailable.\n");
|
Logger::log("Socket Unavailable.\n");
|
||||||
|
|
||||||
|
this->socket_errno = nn::socket::GetLastErrno();
|
||||||
this->socket_log_state = SOCKET_LOG_UNAVAILABLE;
|
this->socket_log_state = SOCKET_LOG_UNAVAILABLE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -56,6 +58,7 @@ nn::Result SocketClient::init(const char* ip, u16 port) {
|
||||||
nn::Result result;
|
nn::Result result;
|
||||||
|
|
||||||
if((result = nn::socket::Connect(this->socket_log_socket, &serverAddress, sizeof(serverAddress))).isFailure()) {
|
if((result = nn::socket::Connect(this->socket_log_socket, &serverAddress, sizeof(serverAddress))).isFailure()) {
|
||||||
|
this->socket_errno = nn::socket::GetLastErrno();
|
||||||
this->socket_log_state = SOCKET_LOG_UNAVAILABLE;
|
this->socket_log_state = SOCKET_LOG_UNAVAILABLE;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +84,7 @@ bool SocketClient::SEND(Packet *packet) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Logger::log("Failed to Fully Send Packet! Result: %d Type: %s Packet Size: %d\n", valread, packetNames[packet->mType], packet->mPacketSize);
|
Logger::log("Failed to Fully Send Packet! Result: %d Type: %s Packet Size: %d\n", valread, packetNames[packet->mType], packet->mPacketSize);
|
||||||
|
this->socket_errno = nn::socket::GetLastErrno();
|
||||||
this->closeSocket();
|
this->closeSocket();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +95,7 @@ bool SocketClient::RECV() {
|
||||||
|
|
||||||
if (this->socket_log_state != SOCKET_LOG_CONNECTED) {
|
if (this->socket_log_state != SOCKET_LOG_CONNECTED) {
|
||||||
Logger::log("Unable To Recieve! Socket Not Connected.\n");
|
Logger::log("Unable To Recieve! Socket Not Connected.\n");
|
||||||
|
this->socket_errno = nn::socket::GetLastErrno();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +110,7 @@ bool SocketClient::RECV() {
|
||||||
valread += result;
|
valread += result;
|
||||||
} else {
|
} else {
|
||||||
Logger::log("Header Read Failed! Value: %d Total Read: %d\n", result, valread);
|
Logger::log("Header Read Failed! Value: %d Total Read: %d\n", result, valread);
|
||||||
|
this->socket_errno = nn::socket::GetLastErrno();
|
||||||
this->closeSocket();
|
this->closeSocket();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -132,6 +138,7 @@ bool SocketClient::RECV() {
|
||||||
}else {
|
}else {
|
||||||
free(packetBuf);
|
free(packetBuf);
|
||||||
Logger::log("Packet Read Failed! Value: %d\nPacket Size: %d\nPacket Type: %s\n", result, header->mPacketSize, packetNames[header->mType]);
|
Logger::log("Packet Read Failed! Value: %d\nPacket Size: %d\nPacket Type: %s\n", result, header->mPacketSize, packetNames[header->mType]);
|
||||||
|
this->socket_errno = nn::socket::GetLastErrno();
|
||||||
this->closeSocket();
|
this->closeSocket();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -154,6 +161,7 @@ bool SocketClient::RECV() {
|
||||||
return true;
|
return true;
|
||||||
} else { // if we error'd, close the socket
|
} else { // if we error'd, close the socket
|
||||||
Logger::log("valread was zero! Disconnecting.\n");
|
Logger::log("valread was zero! Disconnecting.\n");
|
||||||
|
this->socket_errno = nn::socket::GetLastErrno();
|
||||||
this->closeSocket();
|
this->closeSocket();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue