Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara committed Sep 16, 2024
1 parent c8ae841 commit c7280f7
Show file tree
Hide file tree
Showing 13 changed files with 322 additions and 18 deletions.
2 changes: 2 additions & 0 deletions eng/testing/tests.wasi.targets
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasm --engine-arg=max-wasm-stack=134217728</_XHarnessArgs>
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasi --engine-arg=http</_XHarnessArgs>
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasi --engine-arg=inherit-network</_XHarnessArgs>
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasi --engine-arg=tcp</_XHarnessArgs>
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasi --engine-arg=udp</_XHarnessArgs>
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasi --engine-arg=allow-ip-name-lookup</_XHarnessArgs>
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--env --engine-arg=DOTNET_WASI_PRINT_EXIT_CODE=1</_XHarnessArgs>
<_XHarnessArgs Condition="'$(WasmXHarnessArgsCli)' != ''" >$(_XHarnessArgs) $(WasmXHarnessArgsCli)</_XHarnessArgs>
Expand Down
3 changes: 1 addition & 2 deletions src/libraries/System.Net.Sockets/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
<!-- WASI until https:/dotnet/runtime/issues/98957 -->
<UnsupportedOSPlatforms>browser;wasi</UnsupportedOSPlatforms>
<UnsupportedOSPlatforms>browser</UnsupportedOSPlatforms>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- SYSTEM_NET_SOCKETS_DLL is required to allow source-level code sharing for types defined within the
System.Net.Internals namespace. -->
Expand All @@ -15,6 +15,7 @@
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetPlatformIdentifier)' == ''">SR.SystemNetSockets_PlatformNotSupported</GeneratePlatformNotSupportedAssemblyMessage>
<IsApplePlatform Condition="'$(TargetPlatformIdentifier)' == 'osx' or '$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos'">true</IsApplePlatform>
<DefineConstants Condition="'$(IsApplePlatform)' == 'true'">$(DefineConstants);SYSTEM_NET_SOCKETS_APPLE_PLATFROM</DefineConstants>
<DefineConstants Condition="'$(TargetPlatformIdentifier)' == 'wasi'">$(DefineConstants);TARGET_WASI</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetPlatformIdentifier)' != ''">
Expand Down Expand Up @@ -183,11 +184,12 @@
Link="Common\System\Net\CompletionPortHelper.Windows.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'unix' or '$(TargetPlatformIdentifier)' == 'osx' or '$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos'">
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'unix' or '$(TargetPlatformIdentifier)' == 'wasi' or '$(TargetPlatformIdentifier)' == 'osx' or '$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos'">
<Compile Include="System\Net\Sockets\SafeSocketHandle.Unix.cs" />
<Compile Include="System\Net\Sockets\Socket.Unix.cs" />
<Compile Include="System\Net\Sockets\SocketAsyncContext.Unix.cs" />
<Compile Include="System\Net\Sockets\SocketAsyncEngine.Unix.cs" />
<Compile Include="System\Net\Sockets\SocketAsyncEngine.Wasi.cs" Condition="'$(TargetPlatformIdentifier)' == 'wasi'"/>
<Compile Include="System\Net\Sockets\SocketAsyncEventArgs.Unix.cs" />
<Compile Include="System\Net\Sockets\SocketPal.Unix.cs" />
<Compile Include="System\Net\Sockets\UnixDomainSocketEndPoint.Unix.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1348,10 +1348,12 @@ public void SetHandleNonBlocking()
//
if (!_isHandleNonBlocking)
{
#if !TARGET_WASI // WASI-libc doesn't have emulate this for tcp handles, see https:/WebAssembly/wasi-libc/issues/536
if (Interop.Sys.Fcntl.SetIsNonBlocking(_socket, 1) != 0)
{
throw new SocketException((int)SocketPal.GetSocketErrorForErrorCode(Interop.Sys.GetLastError()));
}
#endif

_isHandleNonBlocking = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace System.Net.Sockets
{
internal sealed unsafe class SocketAsyncEngine : IThreadPoolWorkItem
internal sealed unsafe partial class SocketAsyncEngine : IThreadPoolWorkItem
{
private const int EventBufferCount =
#if DEBUG
Expand Down Expand Up @@ -143,6 +143,7 @@ public void UnregisterSocket(IntPtr socketHandle)
_handleToContextMap.TryRemove(socketHandle, out _);
}

#if !TARGET_WASI
private SocketAsyncEngine()
{
_port = (IntPtr)(-1);
Expand All @@ -161,9 +162,11 @@ private SocketAsyncEngine()
}
}

Console.WriteLine("SocketAsyncEngine C");

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build maccatalyst-x64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build osx-x64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-riscv64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build osx-x64 Release AllSubsets_Mono_Interpreter_RuntimeTests monointerpreter)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build osx-arm64 Release NativeAOT_Libraries)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build android-arm64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build tvos-arm64 Release AllSubsets_NativeAOT)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-arm64 Release NativeAOT_Libraries)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build android-arm Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build ios-arm64 Release AllSubsets_NativeAOT)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-arm64 Release AllSubsets_Mono_LLVMAOT)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux_musl-x64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-x64 Release AllSubsets_Mono_LLVMAOT)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-arm64 Release AllSubsets_Mono_Minijit_RuntimeTests minijit)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build ios-arm64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / dotnet-linker-tests (Build osx-x64 release Runtime_Release)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build tvos-arm64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-x64 Release AllSubsets_Mono_LLVMAot_RuntimeTests llvmaot)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux_musl-arm Debug AllSubsets_CoreCLR_ReleaseRuntimeLibs)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build osx-x64 Release AllSubsets_Mono_Minijit_RuntimeTests minijit)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-arm Debug AllSubsets_CoreCLR_ReleaseRuntimeLibs)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / dotnet-linker-tests (Build linux-x64 release Runtime_Release)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux_musl-arm64 Debug AllSubsets_CoreCLR_ReleaseRuntimeLibs)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / dotnet-linker-tests

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / dotnet-linker-tests

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 165 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L165

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(165,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context
fixed (Interop.Sys.SocketEvent** bufferPtr = &_buffer)
{
err = Interop.Sys.CreateSocketEventBuffer(EventBufferCount, bufferPtr);
Console.WriteLine("SocketAsyncEngine D");

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build maccatalyst-x64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build osx-x64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-riscv64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build osx-x64 Release AllSubsets_Mono_Interpreter_RuntimeTests monointerpreter)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build osx-arm64 Release NativeAOT_Libraries)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build android-arm64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build tvos-arm64 Release AllSubsets_NativeAOT)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-arm64 Release NativeAOT_Libraries)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build android-arm Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build ios-arm64 Release AllSubsets_NativeAOT)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-arm64 Release AllSubsets_Mono_LLVMAOT)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux_musl-x64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-x64 Release AllSubsets_Mono_LLVMAOT)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-arm64 Release AllSubsets_Mono_Minijit_RuntimeTests minijit)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build ios-arm64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / dotnet-linker-tests (Build osx-x64 release Runtime_Release)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build tvos-arm64 Release AllSubsets_Mono)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-x64 Release AllSubsets_Mono_LLVMAot_RuntimeTests llvmaot)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux_musl-arm Debug AllSubsets_CoreCLR_ReleaseRuntimeLibs)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build osx-x64 Release AllSubsets_Mono_Minijit_RuntimeTests minijit)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux-arm Debug AllSubsets_CoreCLR_ReleaseRuntimeLibs)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / dotnet-linker-tests (Build linux-x64 release Runtime_Release)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime (Build linux_musl-arm64 Debug AllSubsets_CoreCLR_ReleaseRuntimeLibs)

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / dotnet-linker-tests

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / dotnet-linker-tests

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context

Check failure on line 169 in src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs

View check run for this annotation

Azure Pipelines / runtime

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs#L169

src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Unix.cs(169,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'Console' does not exist in the current context
if (err != Interop.Error.SUCCESS)
{
throw new InternalException(err);
Expand Down Expand Up @@ -217,6 +220,7 @@ private void EventLoop()
Environment.FailFast("Exception thrown from SocketAsyncEngine event loop: " + e.ToString(), e);
}
}
#endif

private void UpdateEventQueueProcessingStage(bool isEventQueueEmpty)
{
Expand Down Expand Up @@ -303,6 +307,7 @@ void IThreadPoolWorkItem.Execute()
} while (Environment.TickCount - startTimeMs < 15 && eventQueue.TryDequeue(out ev));
}

#if !TARGET_WASI
private void FreeNativeResources()
{
if (_buffer != null)
Expand All @@ -314,6 +319,7 @@ private void FreeNativeResources()
Interop.Sys.CloseSocketEventPort(_port);
}
}
#endif // !TARGET_WASI

// The JIT is allowed to arbitrarily extend the lifetime of locals, which may retain SocketAsyncContext references,
// indirectly preventing Socket instances to be finalized, despite being no longer referenced by user code.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Concurrent;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;

namespace System.Net.Sockets
{
internal sealed partial class SocketAsyncEngine : IThreadPoolWorkItem
{
private SocketAsyncEngine()
{
#pragma warning disable CS4014
WasiSocketsEventLoop();
#pragma warning restore CS4014
}

private async Task WasiSocketsEventLoop()
{
try
{
SocketEventHandler handler = new SocketEventHandler(this);
while (true)
{
int numEvents = EventBufferCount;
await WaitForAnySocketPollable().ConfigureAwait(false);

// The native shim is responsible for ensuring this condition.
Debug.Assert(numEvents > 0, $"Unexpected numEvents: {numEvents}");

// Only enqueue a work item if the stage is NotScheduled.
// Otherwise there must be a work item already queued or another thread already handling parallelization.
if (handler.HandleSocketEvents(numEvents) &&
Interlocked.Exchange(
ref _eventQueueProcessingStage,
EventQueueProcessingStage.Scheduled) == EventQueueProcessingStage.NotScheduled)
{
ThreadPool.UnsafeQueueUserWorkItem(this, preferLocal: false);
}
}
}
catch (Exception e)
{
Environment.FailFast("Exception thrown from SocketAsyncEngine event loop: " + e.ToString(), e);
}
}

#pragma warning disable CA1822 // TODO remove
private Task WaitForAnySocketPollable()
{
TaskCompletionSource todo = new TaskCompletionSource();
/* TODO something like this, but with handle->pollable conversion
Interop.Error err = Interop.Sys.WaitForSocketEvents(_port, handler.Buffer, &numEvents);
if (err != Interop.Error.SUCCESS)
{
throw new InternalException(err);
}*/
return todo.Task;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ private static unsafe int SysSend(SafeSocketHandle socket, SocketFlags flags, IL
int startIndex = bufferIndex, startOffset = offset;

int maxBuffers = buffers.Count - startIndex;
#if TARGET_WASI // WASI doesn't have iovecs and recvmsg in preview2
maxBuffers = Math.Max(maxBuffers, 1);
#endif
bool allocOnStack = maxBuffers <= IovStackThreshold;
Span<GCHandle> handles = allocOnStack ? stackalloc GCHandle[IovStackThreshold] : new GCHandle[maxBuffers];
Span<Interop.Sys.IOVector> iovecs = allocOnStack ? stackalloc Interop.Sys.IOVector[IovStackThreshold] : new Interop.Sys.IOVector[maxBuffers];
Expand Down Expand Up @@ -376,6 +379,9 @@ private static unsafe int SysReceive(SafeSocketHandle socket, SocketFlags flags,
Debug.Assert(socket.IsSocket);

int maxBuffers = buffers.Count;
#if TARGET_WASI // WASI doesn't have iovecs and recvmsg in preview2
maxBuffers = Math.Max(maxBuffers, 1);
#endif
bool allocOnStack = maxBuffers <= IovStackThreshold;

// When there are many buffers, reduce the number of pinned buffers based on available bytes.
Expand Down Expand Up @@ -532,6 +538,10 @@ private static unsafe int SysReceiveMessageFrom(
Debug.Assert(socket.IsSocket);

int buffersCount = buffers.Count;
#if TARGET_WASI // WASI doesn't have iovecs and sendmsg in preview2
buffersCount = Math.Max(buffersCount, 1);
#endif

bool allocOnStack = buffersCount <= IovStackThreshold;
Span<GCHandle> handles = allocOnStack ? stackalloc GCHandle[IovStackThreshold] : new GCHandle[buffersCount];
Span<Interop.Sys.IOVector> iovecs = allocOnStack ? stackalloc Interop.Sys.IOVector[IovStackThreshold] : new Interop.Sys.IOVector[buffersCount];
Expand All @@ -554,17 +564,21 @@ private static unsafe int SysReceiveMessageFrom(
fixed (byte* sockAddr = socketAddress)
fixed (Interop.Sys.IOVector* iov = iovecs)
{
#if !TARGET_WASI // WASI doesn't have msg_control and sendmsg in preview2
int cmsgBufferLen = Interop.Sys.GetControlMessageBufferSize(Convert.ToInt32(isIPv4), Convert.ToInt32(isIPv6));
byte* cmsgBuffer = stackalloc byte[cmsgBufferLen];
#endif

var messageHeader = new Interop.Sys.MessageHeader
{
SocketAddress = sockAddr,
SocketAddressLen = socketAddress.Length,
IOVectors = iov,
IOVectorCount = iovCount,
#if !TARGET_WASI // WASI doesn't have msg_control and sendmsg in preview2
ControlBuffer = cmsgBuffer,
ControlBufferLen = cmsgBufferLen
#endif
};

long received = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi</TargetFrameworks>
<IgnoreForCI Condition="'$(TargetOS)' == 'browser'">true</IgnoreForCI>
<EventSourceSupport Condition="'$(TestNativeAot)' == 'true'">true</EventSourceSupport>
<XunitShowProgress Condition="'$(TargetOS)' == 'wasi'">true</XunitShowProgress>
</PropertyGroup>
<ItemGroup>
<Compile Include="Accept.cs" />
Expand Down
1 change: 1 addition & 0 deletions src/mono/sample/wasi/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@


<WasiCommand Condition="'$(_WasiNeedsHttp)' == 'true'" >$(WasiCommand) --wasi http</WasiCommand>
<WasiCommand Condition="'$(_WasiNeedsSocket)' == 'true'" >$(WasiCommand) --wasi inherit-network --wasi tcp --wasi udp --wasi allow-ip-name-lookup</WasiCommand>
<WasiCommand Condition="'$(WasmSingleFileBundle)' != 'true'" >$(WasiCommand) --dir .</WasiCommand>
<WasiCommand >$(WasiCommand) $(_DotnetWasmName)</WasiCommand>
<WasiCommand Condition="'$(WasmSingleFileBundle)' != 'true'" >$(WasiCommand) $(_SampleProjectName)</WasiCommand>
Expand Down
61 changes: 61 additions & 0 deletions src/mono/sample/wasi/sockets-p2/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Net.Http.Headers;
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Net;
using System.Net.Sockets;
using System.Text;

public static class WasiMainWrapper
{
public static async Task<int> MainAsync(string[] args)
{
IPHostEntry ipHostInfo = await Dns.GetHostEntryAsync("example.com");
IPAddress ipAddress = ipHostInfo.AddressList[0];
Console.WriteLine($"IP Address: {ipAddress}");

IPEndPoint ipEndPoint = new(ipAddress, 80);
using Socket client = new(ipEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

await client.ConnectAsync(ipEndPoint);

// Send message.
var message = @"GET / HTTP/1.1
Host: example.com
Accept: */*
";
var messageBytes = Encoding.UTF8.GetBytes(message);
var start = 0;
while (start < messageBytes.Length)
{
start += await client.SendAsync(messageBytes.AsMemory(start), SocketFlags.None);
Console.WriteLine("TODO poll here");
}
Console.WriteLine("GET sent");

// Receive ack.
var buffer = new byte[2048];
var received = await client.ReceiveAsync(buffer, SocketFlags.None);
var response = Encoding.UTF8.GetString(buffer, 0, received);
Console.WriteLine(response);

client.Shutdown(SocketShutdown.Both);

return 0;
}

public static int Main(string[] args)
{
return PollWasiEventLoopUntilResolved((Thread)null!, MainAsync(args));

[UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "PollWasiEventLoopUntilResolved")]
static extern T PollWasiEventLoopUntilResolved<T>(Thread t, Task<T> mainTask);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<_WasiNeedsHttp>true</_WasiNeedsHttp>
<_WasiNeedsSocket>true</_WasiNeedsSocket>
<!--
<WasmSingleFileBundle>true</WasmSingleFileBundle>
<InvariantGlobalization>true</InvariantGlobalization>
-->
</PropertyGroup>

<Target Name="RunSample" DependsOnTargets="RunSampleWithWasmtime" />
</Project>
Loading

0 comments on commit c7280f7

Please sign in to comment.