Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

**/obj/

*.obj

# Visual Studio >=2015 cache/options directory
.vs/

# idea
.idea/

# VSCode
.vscode/

# cache
.cache
4 changes: 0 additions & 4 deletions .idea/.idea.CSZeroMQ/.idea/encodings.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/.idea.CSZeroMQ/.idea/indexLayout.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/.idea.CSZeroMQ/.idea/projectSettingsUpdater.xml

This file was deleted.

122 changes: 0 additions & 122 deletions .idea/.idea.CSZeroMQ/.idea/workspace.xml

This file was deleted.

16 changes: 11 additions & 5 deletions CSZeroMQ.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSZeroMQ", "CSZeroMQ\CSZeroMQ.csproj", "{8AF25931-AD99-4F75-9796-D7BBD19E25BC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSZeroMQ.ExampleApp", "CSZeroMQ.ExampleApp\CSZeroMQ.ExampleApp.csproj", "{85E8C051-962E-42A0-8EE9-E833F558B5F0}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSZeroMQSubscriber", "CSZeroMQSubscriber\CSZeroMQSubscriber.csproj", "{47BED99C-53C7-4ABE-8654-692916F13696}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSZeroMQPublisher", "CSZeroMQPublisher\CSZeroMQPublisher.csproj", "{68053A27-C5D0-4CC7-9693-9B27F710A4DC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -14,9 +16,13 @@ Global
{8AF25931-AD99-4F75-9796-D7BBD19E25BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AF25931-AD99-4F75-9796-D7BBD19E25BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8AF25931-AD99-4F75-9796-D7BBD19E25BC}.Release|Any CPU.Build.0 = Release|Any CPU
{85E8C051-962E-42A0-8EE9-E833F558B5F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85E8C051-962E-42A0-8EE9-E833F558B5F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85E8C051-962E-42A0-8EE9-E833F558B5F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85E8C051-962E-42A0-8EE9-E833F558B5F0}.Release|Any CPU.Build.0 = Release|Any CPU
{47BED99C-53C7-4ABE-8654-692916F13696}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47BED99C-53C7-4ABE-8654-692916F13696}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47BED99C-53C7-4ABE-8654-692916F13696}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47BED99C-53C7-4ABE-8654-692916F13696}.Release|Any CPU.Build.0 = Release|Any CPU
{68053A27-C5D0-4CC7-9693-9B27F710A4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68053A27-C5D0-4CC7-9693-9B27F710A4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68053A27-C5D0-4CC7-9693-9B27F710A4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68053A27-C5D0-4CC7-9693-9B27F710A4DC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
13 changes: 12 additions & 1 deletion CSZeroMQ/CSZeroMQ.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
<Authors>jgcodes2020</Authors>

</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="runtimes\win10_x64\native\libzmq-v143-mt-4_3_5.dll" />
<EmbeddedResource Include="runtimes\linux_x64\native\libzmq.so" />
<EmbeddedResource Include="runtimes\osx_x64\native\libzmq.dylib" />
</ItemGroup>
<!--ItemGroup>
<Content Include="runtimes\win10-x64\native\libzmq.dll">
<PackagePath>runtimes/win10-x64/native/libzmq.dll</PackagePath>
<Pack>true</Pack>
Expand All @@ -31,5 +35,12 @@
<Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup-->

<ItemGroup>
<PackageReference Include="NativeLibraryManager" Version="1.0.23" />
<PackageReference Include="Serilog" Version="4.0.2-dev-02220" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.1-dev-10398" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions CSZeroMQ/Constants/SocketOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ public enum SocketOptionString : int
SocksProxy = 68,
[StringSockOptDescriptor(false)]
ZapDomain = 55,
[StringSockOptDescriptor(true)]
Subscribe = 6,
}

public enum SocketOptionBin : int
Expand Down
47 changes: 47 additions & 0 deletions CSZeroMQ/Native/NativeLibLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Microsoft.Extensions.Logging;
using NativeLibraryManager;
using Serilog.Extensions.Logging;
using System.Reflection;


namespace CSZeroMQ.Native;

public static class NativeLibLoader
{
private static readonly LibraryManager LibManager;
private static readonly LoggerFactory Factory = new LoggerFactory(new[] {new SerilogLoggerProvider() });
private static readonly ResourceAccessor Accessor = new ResourceAccessor(Assembly.GetExecutingAssembly());
static NativeLibLoader()
{
try
{
LibManager = new LibraryManager(
Factory,
new LibraryItem(Platform.MacOs, Bitness.x64,
new LibraryFile("libzmq.dylib", Accessor.Binary("runtimes.osx_x64.native.libzmq.dylib"))),
new LibraryItem(Platform.Windows, Bitness.x64,
new LibraryFile("libzmq.dll", Accessor.Binary("runtimes.win10_x64.native.libzmq-v143-mt-4_3_5.dll"))),
new LibraryItem(Platform.Linux, Bitness.x64,
new LibraryFile("libzmq.so", Accessor.Binary("runtimes.linux_x64.native.libzmq.so")))
);
}
catch (Exception e)
{
Console.WriteLine(e);
throw new Exception("Loading Native Library Issue");
}
}

public static void LoadLibrary()
{
try
{
LibManager.LoadNativeLibrary();
}
catch (Exception e)
{
Console.WriteLine(e);
throw new Exception("Loading Native Library Issue");
}
}
}
11 changes: 9 additions & 2 deletions CSZeroMQ/Native/ZMQ.gen.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Runtime.InteropServices;


namespace CSZeroMQ.Native
{
public unsafe partial struct zmq_msg_t
Expand Down Expand Up @@ -35,9 +36,15 @@ public unsafe partial struct win_zmq_pollitem_t
public partial struct iovec
{
}

public static unsafe partial class ZMQ
public unsafe class ZMQ
{
static ZMQ()
{
// Load the native library when the ZMQ class is accessed for the first time
NativeLibLoader.LoadLibrary();
}

[DllImport("libzmq", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)]
public static extern int zmq_errno();

Expand Down
1 change: 0 additions & 1 deletion CSZeroMQ/ZMQContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using CSZeroMQ.Constants;
using CSZeroMQ.Native;
using static CSZeroMQ.Native.ZMQ;

Expand Down
Loading