mirror of
https://github.com/wiiu-env/homebrew_launcher.git
synced 2024-12-01 00:44:18 +01:00
fixed receive from wiiload and other application that send the header one byte at a time
This commit is contained in:
parent
875969f851
commit
e688b5ee91
@ -9,6 +9,7 @@
|
|||||||
#include "fs/CFile.hpp"
|
#include "fs/CFile.hpp"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include "utils/StringTools.h"
|
#include "utils/StringTools.h"
|
||||||
|
#include "utils/net.h"
|
||||||
|
|
||||||
TcpReceiver::TcpReceiver(int port)
|
TcpReceiver::TcpReceiver(int port)
|
||||||
: GuiFrame(0, 0)
|
: GuiFrame(0, 0)
|
||||||
@ -96,13 +97,14 @@ int TcpReceiver::loadToMemory(s32 clientSocket, u32 ipAddress)
|
|||||||
u32 fileSize = 0;
|
u32 fileSize = 0;
|
||||||
u32 fileSizeUnc = 0;
|
u32 fileSizeUnc = 0;
|
||||||
unsigned char haxx[8];
|
unsigned char haxx[8];
|
||||||
|
memset(haxx, 0, sizeof(haxx));
|
||||||
//skip haxx
|
//skip haxx
|
||||||
recv(clientSocket, haxx, 8, 0);
|
recvwait(clientSocket, haxx, sizeof(haxx));
|
||||||
recv(clientSocket, &fileSize, 4, 0);
|
recvwait(clientSocket, (unsigned char*)&fileSize, sizeof(fileSize));
|
||||||
|
|
||||||
if (haxx[4] > 0 || haxx[5] > 4)
|
if (haxx[4] > 0 || haxx[5] > 4)
|
||||||
{
|
{
|
||||||
recv(clientSocket, &fileSizeUnc, 4, 0); // Compressed protocol, read another 4 bytes
|
recvwait(clientSocket, (unsigned char*)&fileSizeUnc, sizeof(fileSizeUnc)); // Compressed protocol, read another 4 bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 bytesRead = 0;
|
u32 bytesRead = 0;
|
||||||
|
20
src/utils/net.c
Normal file
20
src/utils/net.c
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include "dynamic_libs/socket_functions.h"
|
||||||
|
|
||||||
|
int recvwait(int sock, unsigned char *buffer, int len)
|
||||||
|
{
|
||||||
|
int recvBytes = 0;
|
||||||
|
|
||||||
|
while(len)
|
||||||
|
{
|
||||||
|
int ret = recv(sock, buffer, len, 0);
|
||||||
|
if(ret <= 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
len -= ret;
|
||||||
|
buffer += ret;
|
||||||
|
recvBytes += ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return recvBytes;
|
||||||
|
}
|
14
src/utils/net.h
Normal file
14
src/utils/net.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef __NET_H_
|
||||||
|
#define __NET_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int recvwait(int sock, unsigned char *buffer, int len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user