Skip to content

Commit 90f7cae

Browse files
Merge branch 'live'
2 parents f1d147f + c0887c9 commit 90f7cae

8 files changed

Lines changed: 152 additions & 180 deletions

File tree

WSL/install-win10.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Below are related errors and suggested fixes. Refer to the [WSL troubleshooting
117117

118118
- **WslRegisterDistribution failed with error 0x8007019e**
119119
- The Windows Subsystem for Linux optional component is not enabled:
120-
- Open **Control Panel** -> **Programs and Features** -> **Turn Windows Feature on or off** -> Check **Windows Subsystem for Linux** or using the PowerShell cmdlet mentioned at the begining of this article.
120+
- Open **Control Panel** -> **Programs and Features** -> **Turn Windows Feature on or off** -> Check **Windows Subsystem for Linux** or using the PowerShell cmdlet mentioned at the beginning of this article.
121121

122122
- **Installation failed with error 0x80070003 or error 0x80370102**
123123
- Please make sure that virtualization is enabled inside of your computer's BIOS. The instructions on how to do this will vary from computer to computer, and will most likely be under CPU related options.

WSL/wsl-config.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,12 @@ These settings affect the VM that powers any WSL 2 distribution.
341341
|:----|:----|:----|:----|
342342
| kernel | string | The Microsoft built kernel provided inbox | An absolute Windows path to a custom Linux kernel. |
343343
| memory | size | 80% of your total memory on Windows | How much memory to assign to the WSL 2 VM. |
344-
| processors | number | The same number of processors on Windows | How many processors to assign ot the WSL 2 VM. |
344+
| processors | number | The same number of processors on Windows | How many processors to assign to the WSL 2 VM. |
345345
| localhostForwarding | boolean | `true` | Boolean specifying if ports bound to wildcard or localhost in the WSL 2 VM should be connectable from the host via localhost:port. |
346346
| kernelCommandLine | string | Blank | Additional kernel command line arguments. |
347347
| swap | size | 25% of memory size on Windows rounded up to the nearest GB | How much swap space to add to the WSL 2 VM, 0 for no swap file. |
348-
| swapFile | size | %USERPROFILE%\AppData\Local\Temp\swap.vhdx | An absolute Windows path to the swap virtual hard disk. |
348+
| swapFile | string | %USERPROFILE%\AppData\Local\Temp\swap.vhdx | An absolute Windows path to the swap virtual hard disk. |
349349

350350
Entries with the `path` value must be Windows paths with escaped backslashes, e.g: `C:\\Temp\\myCustomKernel`
351351

352-
Entries with the `size` value must be a size followed by a unit, for example `8GB` or `512MB`.
352+
Entries with the `size` value must be a size followed by a unit, for example `8GB` or `512MB`.

WSL/wsl2-kernel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.localizationpriority: high
1212
To manually update the Linux kernel inside of WSL 2 please follow these steps.
1313

1414
> [!NOTE]
15-
> If the installer cant find WSL 1 right click the Linux kernel update installer, then press uninstall then rerun the installer
15+
> If the installer can't find WSL 1, right-click the Linux kernel update installer and press "Uninstall", then rerun the installer.
1616
1717
## Download the Linux kernel update package
1818

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
1-
#include <sys/socket.h>
2-
#include <sys/un.h>
3-
#include <stdio.h>
4-
#include <stdlib.h>
5-
#include <unistd.h>
1+
#include "header.h"
62

7-
char *server_full_path = "bind.sock";
3+
int main(int argc, char* argv[]) {
4+
struct sockaddr_un serverAddr = { 0 };
5+
int serverFd = 0;
86

9-
int main(int argc, char *argv[]) {
10-
struct sockaddr_un serverAddr;
11-
int serverFd, rc, clientFd;
12-
int acceptFd;
13-
socklen_t addrLen;
7+
if ((serverFd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
8+
perror("socket error");
9+
goto ErrorExit;
10+
}
1411

15-
if ((serverFd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
16-
perror("socket error");
17-
goto ErrorExit;
18-
}
19-
20-
// bind the server.
21-
memset(&serverAddr, 0, sizeof(serverAddr));
22-
serverAddr.sun_family = AF_UNIX;
23-
strncpy(serverAddr.sun_path, server_full_path, sizeof(serverAddr.sun_path)-1);
24-
printf("binding to: '%s'\n", server_full_path);
25-
if (bind(serverFd, (struct sockaddr*)&serverAddr, sizeof(serverAddr)) == -1) {
26-
perror("server bind error");
27-
goto ErrorExit;
28-
}
12+
// bind the server.
13+
serverAddr.sun_family = AF_UNIX;
14+
strncpy(serverAddr.sun_path, BIND_SOCKET, sizeof(serverAddr.sun_path) - 1);
15+
printf("binding to: '%s'\n", BIND_SOCKET);
16+
if (bind(serverFd, (struct sockaddr*)&serverAddr, sizeof(serverAddr)) == -1) {
17+
perror("server bind error");
18+
goto ErrorExit;
19+
}
2920

3021
ErrorExit:
31-
unlink(server_full_path);
32-
return 0;
22+
unlink(BIND_SOCKET);
23+
return 0;
3324
}
Lines changed: 56 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,59 @@
1-
#include <sys/socket.h>
2-
#include <sys/un.h>
3-
#include <stdio.h>
4-
#include <stdlib.h>
5-
#include <unistd.h>
1+
#include "header.h"
2+
3+
int main(int argc, char* argv[]) {
4+
char Buf[100] = { 0 };
5+
ssize_t BytesRecvd = 0;
6+
struct sockaddr_un clientAddr = { 0 };
7+
struct sockaddr_un serverAddr = { 0 };
8+
struct sockaddr_un address = { 0 };
9+
char serverAddress[100] = { 0 };
10+
int serverFd = 0, rc = 0, clientFd = 0;
11+
int acceptFd = 0;
12+
socklen_t addrLen = 0;
13+
14+
if ((clientFd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
15+
perror("clientFd socket error");
16+
goto ErrorExit;
17+
}
18+
19+
clientAddr.sun_family = AF_UNIX;
20+
strncpy(clientAddr.sun_path, CLIENT_SOCKET, sizeof(clientAddr.sun_path) - 1);
21+
if (bind(clientFd, (struct sockaddr*)&clientAddr, sizeof(clientAddr)) == -1) {
22+
perror("server bind error");
23+
goto ErrorExit;
24+
}
25+
26+
addrLen = sizeof(clientAddr);
27+
if (getsockname(clientFd, (struct sockaddr*)&clientAddr, &addrLen) == -1) {
28+
perror("getsockname(client)");
29+
goto ErrorExit;
30+
}
31+
32+
printf("getsockname returned: %s, addressize: %d\n", clientAddr.sun_path, addrLen);
33+
serverAddr.sun_family = AF_UNIX;
34+
strncpy(serverAddr.sun_path, SERVER_SOCKET, sizeof(serverAddr.sun_path));
35+
printf("client: connecting to %s\n", SERVER_SOCKET);
36+
if (connect(clientFd, (struct sockaddr*)&serverAddr, sizeof(serverAddr)) == -1) {
37+
perror("connect error");
38+
goto ErrorExit;
39+
}
40+
41+
printf("client: connected to the server\n");
42+
addrLen = sizeof(clientAddr);
43+
if (getpeername(clientFd, (struct sockaddr*)&clientAddr, &addrLen) == -1) {
44+
perror("getpeername(client)");
45+
goto ErrorExit;
46+
}
47+
48+
printf("getpeername returned: %s, addressize: %d\n", clientAddr.sun_path, addrLen);
49+
if ((BytesRecvd = recv(clientFd, Buf, sizeof(Buf), 0)) == -1) {
50+
perror("recv");
51+
goto ErrorExit;
52+
}
53+
54+
printf("received: %zd bytes, %s\n", BytesRecvd, Buf);
655

7-
char *server_full_path = "server.sock";
8-
char *client_full_path = "client.sock";
9-
10-
int main(int argc, char *argv[]) {
11-
char Buf[100];
12-
ssize_t BytesRecvd;
13-
struct sockaddr_un clientAddr = {0};
14-
struct sockaddr_un serverAddr = {0};
15-
struct sockaddr_un address;
16-
char serverAddress[100] = {0};
17-
int serverFd, rc, clientFd;
18-
int acceptFd;
19-
socklen_t addrLen;
20-
21-
if ((clientFd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
22-
perror("clientFd socket error");
23-
goto ErrorExit;
24-
}
25-
26-
memset(&clientAddr, 0, sizeof(clientAddr));
27-
clientAddr.sun_family = AF_UNIX;
28-
strncpy(clientAddr.sun_path, client_full_path, sizeof(clientAddr.sun_path)-1);
29-
if (bind(clientFd, (struct sockaddr*)&clientAddr, sizeof(clientAddr)) == -1) {
30-
perror("server bind error");
31-
goto ErrorExit;
32-
}
33-
34-
addrLen = sizeof(clientAddr);
35-
memset(&clientAddr, 0, sizeof(clientAddr));
36-
if (getsockname(clientFd, (struct sockaddr*)&clientAddr, &addrLen) == -1) {
37-
perror("getsockname(client)");
38-
goto ErrorExit;
39-
}
40-
41-
printf("getsockname returned: %s, addressize: %d\n", clientAddr.sun_path, addrLen);
42-
memset(&serverAddr, 0, sizeof(serverAddr));
43-
serverAddr.sun_family = AF_UNIX;
44-
strncpy(serverAddr.sun_path, server_full_path, sizeof(serverAddr.sun_path));
45-
printf("client: connecting to %s\n", serverAddress);
46-
if (connect(clientFd, (struct sockaddr*)&serverAddr, sizeof(serverAddr)) == -1) {
47-
perror("connect error");
48-
goto ErrorExit;
49-
}
50-
51-
printf("client: connected to the server\n");
52-
addrLen = sizeof(clientAddr);
53-
memset(&clientAddr, 0, sizeof(clientAddr));
54-
if (getpeername(clientFd, (struct sockaddr*)&clientAddr, &addrLen) == -1) {
55-
perror("getpeername(client)");
56-
goto ErrorExit;
57-
}
58-
59-
printf("getpeername returned: %s, addressize: %d\n", clientAddr.sun_path, addrLen);
60-
memset(Buf, 0, sizeof(Buf));
61-
if ((BytesRecvd = recv(clientFd, Buf, sizeof(Buf), 0)) == -1) {
62-
perror("recv");
63-
goto ErrorExit;
64-
}
65-
66-
printf("received: %zd bytes, %s\n", BytesRecvd, Buf);
67-
6856
ErrorExit:
69-
unlink(client_full_path);
70-
return 0;
57+
unlink(CLIENT_SOCKET);
58+
return 0;
7159
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <sys/socket.h>
2+
#include <sys/un.h>
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include <unistd.h>
6+
7+
#define SERVER_SOCKET "server.sock"
8+
#define CLIENT_SOCKET "client.sock"
9+
#define BIND_SOCKET "bind.sock"
Lines changed: 58 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,61 @@
1-
#include <sys/socket.h>
2-
#include <sys/un.h>
3-
#include <stdio.h>
4-
#include <stdlib.h>
5-
#include <unistd.h>
6-
7-
//char *server_path = "/var/run/server";
8-
char *client_path = "./client";
9-
char *server_full_path = "server.sock";
10-
//char *client_path = "\0hidden";
11-
12-
int main(int argc, char *argv[]) {
13-
ssize_t BytesSent;
14-
struct sockaddr_un serverAddr;
15-
struct sockaddr_un clientAddr;
16-
struct sockaddr_un address;
17-
char buf[100] = "this is a test";
18-
int serverFd, rc, clientFd;
19-
int acceptFd;
20-
socklen_t addrLen;
21-
22-
if (argc > 1) client_path=argv[1];
23-
24-
if ((serverFd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
25-
perror("socket error");
26-
goto ErrorExit;
27-
}
28-
29-
// bind the server.
30-
memset(&serverAddr, 0, sizeof(serverAddr));
31-
serverAddr.sun_family = AF_UNIX;
32-
strncpy(serverAddr.sun_path, server_full_path, sizeof(serverAddr.sun_path)-1);
33-
if (bind(serverFd, (struct sockaddr*)&serverAddr, sizeof(serverAddr)) == -1) {
34-
perror("server bind error");
35-
goto ErrorExit;
36-
}
37-
38-
// listen
39-
if (listen(serverFd, 5) == -1) {
40-
perror("listen error");
41-
goto ErrorExit;
42-
}
43-
44-
memset(&address, 0, sizeof(address));
45-
addrLen = sizeof(address);
46-
if (getsockname(serverFd, (struct sockaddr *)&address, &addrLen) == -1) {
47-
perror("getsockname error");
48-
goto ErrorExit;
49-
}
50-
51-
printf("getsockname on listening socket: %s\n", address.sun_path);
52-
printf("server listening on: %s\n", server_full_path);
53-
fflush(stdout);
54-
55-
// accept connection
56-
addrLen = sizeof(address);
57-
memset(&address, 0, sizeof(address));
58-
if ((acceptFd = accept(serverFd, (struct sockaddr*)&address, &addrLen)) == -1) {
59-
perror("accept error");
60-
goto ErrorExit;
61-
}
62-
63-
printf("accept returned address: %s, address size: %d\n", address.sun_path, addrLen);
64-
if ((BytesSent = send(acceptFd, buf, strlen(buf), 0)) == -1) {
65-
perror("send");
66-
goto ErrorExit;
67-
}
68-
69-
printf("sent data successfully, bytes sent: %zd, data: %s\n", BytesSent, buf);
1+
#include "header.h"
2+
3+
int main(int argc, char* argv[]) {
4+
ssize_t BytesSent = 0;
5+
struct sockaddr_un serverAddr = { 0 };
6+
struct sockaddr_un tmpAddr = { 0 };
7+
char buf[100] = "this is a test";
8+
int serverFd = 0, acceptFd = 0;
9+
socklen_t addrLen = 0;
10+
11+
if ((serverFd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
12+
perror("socket error");
13+
goto ErrorExit;
14+
}
15+
16+
// bind the server.
17+
memset(&serverAddr, 0, sizeof(serverAddr));
18+
serverAddr.sun_family = AF_UNIX;
19+
strncpy(serverAddr.sun_path, SERVER_SOCKET, sizeof(serverAddr.sun_path) - 1);
20+
if (bind(serverFd, (struct sockaddr*)&serverAddr, sizeof(serverAddr)) == -1) {
21+
perror("server bind error");
22+
goto ErrorExit;
23+
}
24+
25+
// listen
26+
if (listen(serverFd, 5) == -1) {
27+
perror("listen error");
28+
goto ErrorExit;
29+
}
30+
31+
addrLen = sizeof(tmpAddr);
32+
memset(&tmpAddr, 0, sizeof(tmpAddr));
33+
if (getsockname(serverFd, (struct sockaddr*)&tmpAddr, &addrLen) == -1) {
34+
perror("getsockname error");
35+
goto ErrorExit;
36+
}
37+
38+
printf("getsockname on listening socket: %s\n", tmpAddr.sun_path);
39+
printf("server listening on: %s\n", SERVER_SOCKET);
40+
fflush(stdout);
41+
42+
// accept connection
43+
addrLen = sizeof(tmpAddr);
44+
memset(&tmpAddr, 0, sizeof(tmpAddr));
45+
if ((acceptFd = accept(serverFd, (struct sockaddr*)&tmpAddr, &addrLen)) == -1) {
46+
perror("accept error");
47+
goto ErrorExit;
48+
}
49+
50+
printf("accept returned address: %s, address size: %d\n", tmpAddr.sun_path, addrLen);
51+
if ((BytesSent = send(acceptFd, buf, strlen(buf), 0)) == -1) {
52+
perror("send");
53+
goto ErrorExit;
54+
}
55+
56+
printf("sent data successfully, bytes sent: %zd, data: %s\n", BytesSent, buf);
7057

7158
ErrorExit:
72-
unlink(server_full_path);
73-
//unlink(client_path);
74-
return 0;
59+
unlink(SERVER_SOCKET);
60+
return 0;
7561
}

0 commit comments

Comments
 (0)