Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eabea0f1a | ||
|
|
82635217c5 | ||
|
|
0ff24f8744 | ||
|
|
dd13c4b6cc | ||
|
|
639ed9be89 | ||
|
|
ff581e8b44 | ||
|
|
1a8de46fb7 | ||
|
|
ad699b35c0 |
@@ -22,3 +22,4 @@ repository can create a new release.
|
||||
1. Update the changelog to whatever makes sense for this release. It should be
|
||||
focused on user-facing changes.
|
||||
1. Confirm all assets are uploaded for all the supported platforms.
|
||||
1. Merge the Pull Request into `main` and you're done :tada:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "desktop-trampoline",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"main": "index.js",
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
||||
@@ -66,7 +66,9 @@ int runTrampolineClient(SOCKET *outSocket, int argc, char **argv, char **envp) {
|
||||
*outSocket = socket;
|
||||
|
||||
if (connectSocket(socket, desktopPort) != 0) {
|
||||
printSocketError("ERROR: Couldn't connect to 127.0.0.1:%d", desktopPort);
|
||||
printSocketError("ERROR: Couldn't connect to 127.0.0.1:%d - Please make "
|
||||
"sure you don't have an antivirus or firewall blocking "
|
||||
"this connection.", desktopPort);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
27
src/socket.c
27
src/socket.c
@@ -6,13 +6,30 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
||||
#define MAX_WSA_ERROR_DESCRIPTION_LENGTH 4096
|
||||
|
||||
void getWSALastErrorDescription(wchar_t *buffer, int bufferLength) {
|
||||
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, WSAGetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPWSTR)buffer, bufferLength - 1, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int initializeNetwork(void) {
|
||||
#ifdef WINDOWS
|
||||
// Initialize Winsock
|
||||
WSADATA wsaData;
|
||||
int result = WSAStartup(MAKEWORD(2,2), &wsaData);
|
||||
if (result != NO_ERROR) {
|
||||
fprintf(stderr, "ERROR: WSAStartup failed: %d\n", result);
|
||||
wchar_t errorDescription[MAX_WSA_ERROR_DESCRIPTION_LENGTH];
|
||||
getWSALastErrorDescription(errorDescription, MAX_WSA_ERROR_DESCRIPTION_LENGTH);
|
||||
|
||||
fprintf(stderr, "ERROR: WSAStartup failed (%d). Error %ld: %ls\n",
|
||||
result, WSAGetLastError(), errorDescription);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
@@ -55,8 +72,7 @@ int readSocket(SOCKET socket, void *buffer, size_t length) {
|
||||
return recv(socket, buffer, length, 0);
|
||||
}
|
||||
|
||||
void printSocketError(char *fmt, ...)
|
||||
{
|
||||
void printSocketError(char *fmt, ...) {
|
||||
char formatted_string[4096];
|
||||
|
||||
va_list argptr;
|
||||
@@ -65,7 +81,10 @@ void printSocketError(char *fmt, ...)
|
||||
va_end(argptr);
|
||||
|
||||
#ifdef WINDOWS
|
||||
fprintf(stderr, "%s: %ld\n", formatted_string, WSAGetLastError());
|
||||
wchar_t errorDescription[MAX_WSA_ERROR_DESCRIPTION_LENGTH];
|
||||
getWSALastErrorDescription(errorDescription, MAX_WSA_ERROR_DESCRIPTION_LENGTH);
|
||||
|
||||
fprintf(stderr, "%s (%ld): %ls\n", formatted_string, WSAGetLastError(), errorDescription);
|
||||
#else
|
||||
fprintf(stderr, "%s (%d): %s\n", formatted_string, errno, strerror(errno));
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user