diff --git a/servefiles/servefiles.py b/servefiles/servefiles.py index 2f9ca22..5210ebd 100644 --- a/servefiles/servefiles.py +++ b/servefiles/servefiles.py @@ -67,20 +67,9 @@ try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((ip, 5000)) - try: - payloadBytes = bytes(payload, "ascii") - except: - payloadBytes = payload.encode("ascii") + payloadBytes = payload.encode("ascii") - networkPayload = struct.pack('!L', len(payloadBytes)) + payloadBytes - - sentLength = 0 - while sentLength < len(networkPayload): - sent = sock.send(networkPayload[sentLength:]) - if sent == 0: - raise RuntimeError("Socket connection broken.") - - sentLength += sent + sock.sendall(struct.pack('!L', len(payloadBytes)) + payloadBytes) while len(sock.recv(1)) < 1: time.sleep(0.05) diff --git a/source/ui/section/remoteinstall.c b/source/ui/section/remoteinstall.c index 1908d00..be95ff0 100644 --- a/source/ui/section/remoteinstall.c +++ b/source/ui/section/remoteinstall.c @@ -80,7 +80,7 @@ static int remoteinstall_network_recvwait(int sockfd, void* buf, size_t len, int int ret = 0; size_t read = 0; - while(((ret = recv(sockfd, buf + read, len - read, flags)) >= 0 && (read += ret) < len) || errno == EAGAIN) { + while((((ret = recv(sockfd, buf + read, len - read, flags)) > 0 && (read += ret) < len) || errno == EAGAIN) && !(hidKeysDown() & KEY_B)) { errno = 0; } @@ -92,7 +92,7 @@ static int remoteinstall_network_sendwait(int sockfd, void* buf, size_t len, int int ret = 0; size_t written = 0; - while(((ret = send(sockfd, buf + written, len - written, flags)) >= 0 && (written += ret) < len) || errno == EAGAIN) { + while((((ret = send(sockfd, buf + written, len - written, flags)) > 0 && (written += ret) < len) || errno == EAGAIN) && !(hidKeysDown() & KEY_B)) { errno = 0; }