diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10ae7e4 --- /dev/null +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/.idea/.idea.CSZeroMQ/.idea/encodings.xml b/.idea/.idea.CSZeroMQ/.idea/encodings.xml deleted file mode 100644 index df87cf9..0000000 --- a/.idea/.idea.CSZeroMQ/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/.idea.CSZeroMQ/.idea/indexLayout.xml b/.idea/.idea.CSZeroMQ/.idea/indexLayout.xml deleted file mode 100644 index 7b08163..0000000 --- a/.idea/.idea.CSZeroMQ/.idea/indexLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/.idea.CSZeroMQ/.idea/projectSettingsUpdater.xml b/.idea/.idea.CSZeroMQ/.idea/projectSettingsUpdater.xml deleted file mode 100644 index 4bb9f4d..0000000 --- a/.idea/.idea.CSZeroMQ/.idea/projectSettingsUpdater.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/.idea.CSZeroMQ/.idea/workspace.xml b/.idea/.idea.CSZeroMQ/.idea/workspace.xml deleted file mode 100644 index a737a22..0000000 --- a/.idea/.idea.CSZeroMQ/.idea/workspace.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - - CSZeroMQ.Example/CSZeroMQ.Example.csproj - CSZeroMQ.ExampleApp/CSZeroMQ.ExampleApp.csproj - CSZeroMQ.Tests/CSZeroMQ.Tests.csproj - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1685280132487 - - - 1686411073655 - - - - - - - - \ No newline at end of file diff --git a/CSZeroMQ.sln b/CSZeroMQ.sln index 8f495d8..cf9c1a6 100644 --- a/CSZeroMQ.sln +++ b/CSZeroMQ.sln @@ -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 @@ -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 diff --git a/CSZeroMQ/CSZeroMQ.csproj b/CSZeroMQ/CSZeroMQ.csproj index 6ba83c7..f523630 100644 --- a/CSZeroMQ/CSZeroMQ.csproj +++ b/CSZeroMQ/CSZeroMQ.csproj @@ -14,8 +14,12 @@ jgcodes2020 - + + + + + + + + + + + diff --git a/CSZeroMQ/Constants/SocketOption.cs b/CSZeroMQ/Constants/SocketOption.cs index d8396ac..082a59f 100644 --- a/CSZeroMQ/Constants/SocketOption.cs +++ b/CSZeroMQ/Constants/SocketOption.cs @@ -182,6 +182,8 @@ public enum SocketOptionString : int SocksProxy = 68, [StringSockOptDescriptor(false)] ZapDomain = 55, + [StringSockOptDescriptor(true)] + Subscribe = 6, } public enum SocketOptionBin : int diff --git a/CSZeroMQ/Native/NativeLibLoader.cs b/CSZeroMQ/Native/NativeLibLoader.cs new file mode 100644 index 0000000..6da46f7 --- /dev/null +++ b/CSZeroMQ/Native/NativeLibLoader.cs @@ -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"); + } + } +} \ No newline at end of file diff --git a/CSZeroMQ/Native/ZMQ.gen.cs b/CSZeroMQ/Native/ZMQ.gen.cs index 7722b88..85f3c1a 100644 --- a/CSZeroMQ/Native/ZMQ.gen.cs +++ b/CSZeroMQ/Native/ZMQ.gen.cs @@ -1,5 +1,6 @@ using System.Runtime.InteropServices; + namespace CSZeroMQ.Native { public unsafe partial struct zmq_msg_t @@ -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(); diff --git a/CSZeroMQ/ZMQContext.cs b/CSZeroMQ/ZMQContext.cs index a6f0d7a..b2f0b61 100644 --- a/CSZeroMQ/ZMQContext.cs +++ b/CSZeroMQ/ZMQContext.cs @@ -1,4 +1,3 @@ -using CSZeroMQ.Constants; using CSZeroMQ.Native; using static CSZeroMQ.Native.ZMQ; diff --git a/CSZeroMQ/obj/CSZeroMQ.csproj.nuget.dgspec.json b/CSZeroMQ/obj/CSZeroMQ.csproj.nuget.dgspec.json deleted file mode 100644 index f5dcef2..0000000 --- a/CSZeroMQ/obj/CSZeroMQ.csproj.nuget.dgspec.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "format": 1, - "restore": { - "/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/CSZeroMQ.csproj": {} - }, - "projects": { - "/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/CSZeroMQ.csproj": { - "version": "0.1.1-preview1", - "restore": { - "projectUniqueName": "/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/CSZeroMQ.csproj", - "projectName": "CSZeroMQ", - "projectPath": "/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/CSZeroMQ.csproj", - "packagesPath": "/home/jgcodes/.nuget/packages/", - "outputPath": "/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/obj/", - "projectStyle": "PackageReference", - "configFilePaths": [ - "/home/jgcodes/.nuget/NuGet/NuGet.Config" - ], - "originalTargetFrameworks": [ - "net6.0" - ], - "sources": { - "https://api.nuget.org/v3/index.json": {} - }, - "frameworks": { - "net6.0": { - "targetAlias": "net6.0", - "projectReferences": {} - } - }, - "warningProperties": { - "warnAsError": [ - "NU1605" - ] - } - }, - "frameworks": { - "net6.0": { - "targetAlias": "net6.0", - "imports": [ - "net461", - "net462", - "net47", - "net471", - "net472", - "net48", - "net481" - ], - "assetTargetFallback": true, - "warn": true, - "downloadDependencies": [ - { - "name": "Microsoft.AspNetCore.App.Ref", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.AspNetCore.App.Runtime.linux-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.AspNetCore.App.Runtime.osx-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.AspNetCore.App.Runtime.win-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Host.linux-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Host.osx-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Host.win-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Runtime.linux-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Runtime.osx-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Runtime.win-x64", - "version": "[6.0.16, 6.0.16]" - } - ], - "frameworkReferences": { - "Microsoft.NETCore.App": { - "privateAssets": "all" - } - }, - "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/7.0.105/RuntimeIdentifierGraph.json" - } - }, - "runtimes": { - "linux-x64": { - "#import": [] - }, - "osx-x64": { - "#import": [] - }, - "win10-x64": { - "#import": [] - } - } - } - } -} \ No newline at end of file diff --git a/CSZeroMQ/obj/CSZeroMQ.csproj.nuget.g.props b/CSZeroMQ/obj/CSZeroMQ.csproj.nuget.g.props deleted file mode 100644 index 72b5bc7..0000000 --- a/CSZeroMQ/obj/CSZeroMQ.csproj.nuget.g.props +++ /dev/null @@ -1,15 +0,0 @@ - - - - True - NuGet - $(MSBuildThisFileDirectory)project.assets.json - /home/jgcodes/.nuget/packages/ - /home/jgcodes/.nuget/packages/ - PackageReference - 6.5.0 - - - - - \ No newline at end of file diff --git a/CSZeroMQ/obj/CSZeroMQ.csproj.nuget.g.targets b/CSZeroMQ/obj/CSZeroMQ.csproj.nuget.g.targets deleted file mode 100644 index 3dc06ef..0000000 --- a/CSZeroMQ/obj/CSZeroMQ.csproj.nuget.g.targets +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/CSZeroMQ/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs b/CSZeroMQ/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs deleted file mode 100644 index 4257f4b..0000000 --- a/CSZeroMQ/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs +++ /dev/null @@ -1,4 +0,0 @@ -// -using System; -using System.Reflection; -[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")] diff --git a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.AssemblyInfo.cs b/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.AssemblyInfo.cs deleted file mode 100644 index 99159a5..0000000 --- a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.AssemblyInfo.cs +++ /dev/null @@ -1,22 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using System; -using System.Reflection; - -[assembly: System.Reflection.AssemblyCompanyAttribute("jgcodes2020")] -[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] -[assembly: System.Reflection.AssemblyFileVersionAttribute("0.1.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("0.1.0")] -[assembly: System.Reflection.AssemblyProductAttribute("CSZeroMQ")] -[assembly: System.Reflection.AssemblyTitleAttribute("CSZeroMQ")] -[assembly: System.Reflection.AssemblyVersionAttribute("0.1.0.0")] - -// Generated by the MSBuild WriteCodeFragment class. - diff --git a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.AssemblyInfoInputs.cache b/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.AssemblyInfoInputs.cache deleted file mode 100644 index 7917b70..0000000 --- a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.AssemblyInfoInputs.cache +++ /dev/null @@ -1 +0,0 @@ -5752c0a792552851760cb04a9ba858eb72b36111 diff --git a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.GeneratedMSBuildEditorConfig.editorconfig b/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.GeneratedMSBuildEditorConfig.editorconfig deleted file mode 100644 index 23ba999..0000000 --- a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.GeneratedMSBuildEditorConfig.editorconfig +++ /dev/null @@ -1,11 +0,0 @@ -is_global = true -build_property.TargetFramework = net7.0 -build_property.TargetPlatformMinVersion = -build_property.UsingMicrosoftNETSdkWeb = -build_property.ProjectTypeGuids = -build_property.InvariantGlobalization = -build_property.PlatformNeutralAssembly = -build_property.EnforceExtendedAnalyzerRules = -build_property._SupportedPlatformList = Linux,macOS,Windows -build_property.RootNamespace = CSZeroMQ -build_property.ProjectDir = /home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/ diff --git a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.GlobalUsings.g.cs b/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.GlobalUsings.g.cs deleted file mode 100644 index 8578f3d..0000000 --- a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.GlobalUsings.g.cs +++ /dev/null @@ -1,8 +0,0 @@ -// -global using global::System; -global using global::System.Collections.Generic; -global using global::System.IO; -global using global::System.Linq; -global using global::System.Net.Http; -global using global::System.Threading; -global using global::System.Threading.Tasks; diff --git a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.assets.cache b/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.assets.cache deleted file mode 100644 index b9ecad8..0000000 Binary files a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.assets.cache and /dev/null differ diff --git a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.csproj.AssemblyReference.cache b/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.csproj.AssemblyReference.cache deleted file mode 100644 index f8e9424..0000000 Binary files a/CSZeroMQ/obj/Debug/net7.0/CSZeroMQ.csproj.AssemblyReference.cache and /dev/null differ diff --git a/CSZeroMQ/obj/project.assets.json b/CSZeroMQ/obj/project.assets.json deleted file mode 100644 index 2654f94..0000000 --- a/CSZeroMQ/obj/project.assets.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "version": 3, - "targets": { - "net6.0": {}, - "net6.0/linux-x64": {}, - "net6.0/osx-x64": {}, - "net6.0/win10-x64": {} - }, - "libraries": {}, - "projectFileDependencyGroups": { - "net6.0": [] - }, - "packageFolders": { - "/home/jgcodes/.nuget/packages/": {} - }, - "project": { - "version": "0.1.1-preview1", - "restore": { - "projectUniqueName": "/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/CSZeroMQ.csproj", - "projectName": "CSZeroMQ", - "projectPath": "/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/CSZeroMQ.csproj", - "packagesPath": "/home/jgcodes/.nuget/packages/", - "outputPath": "/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/obj/", - "projectStyle": "PackageReference", - "configFilePaths": [ - "/home/jgcodes/.nuget/NuGet/NuGet.Config" - ], - "originalTargetFrameworks": [ - "net6.0" - ], - "sources": { - "https://api.nuget.org/v3/index.json": {} - }, - "frameworks": { - "net6.0": { - "targetAlias": "net6.0", - "projectReferences": {} - } - }, - "warningProperties": { - "warnAsError": [ - "NU1605" - ] - } - }, - "frameworks": { - "net6.0": { - "targetAlias": "net6.0", - "imports": [ - "net461", - "net462", - "net47", - "net471", - "net472", - "net48", - "net481" - ], - "assetTargetFallback": true, - "warn": true, - "downloadDependencies": [ - { - "name": "Microsoft.AspNetCore.App.Ref", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.AspNetCore.App.Runtime.linux-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.AspNetCore.App.Runtime.osx-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.AspNetCore.App.Runtime.win-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Host.linux-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Host.osx-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Host.win-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Runtime.linux-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Runtime.osx-x64", - "version": "[6.0.16, 6.0.16]" - }, - { - "name": "Microsoft.NETCore.App.Runtime.win-x64", - "version": "[6.0.16, 6.0.16]" - } - ], - "frameworkReferences": { - "Microsoft.NETCore.App": { - "privateAssets": "all" - } - }, - "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/7.0.105/RuntimeIdentifierGraph.json" - } - }, - "runtimes": { - "linux-x64": { - "#import": [] - }, - "osx-x64": { - "#import": [] - }, - "win10-x64": { - "#import": [] - } - } - } -} \ No newline at end of file diff --git a/CSZeroMQ/obj/project.nuget.cache b/CSZeroMQ/obj/project.nuget.cache deleted file mode 100644 index 78561fe..0000000 --- a/CSZeroMQ/obj/project.nuget.cache +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": 2, - "dgSpecHash": "bTjQ+UGih3PXDMskDCNAwkuI7iTYgEn6op4F/Hn3DX2Xf5QnmhlcFfGZmokwiNPu+qOCR/ZgGDG4i6LfkVw7bQ==", - "success": true, - "projectFilePath": "/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/CSZeroMQ.csproj", - "expectedPackageFiles": [ - "/home/jgcodes/.nuget/packages/microsoft.netcore.app.runtime.win-x64/6.0.16/microsoft.netcore.app.runtime.win-x64.6.0.16.nupkg.sha512", - "/home/jgcodes/.nuget/packages/microsoft.netcore.app.runtime.linux-x64/6.0.16/microsoft.netcore.app.runtime.linux-x64.6.0.16.nupkg.sha512", - "/home/jgcodes/.nuget/packages/microsoft.netcore.app.runtime.osx-x64/6.0.16/microsoft.netcore.app.runtime.osx-x64.6.0.16.nupkg.sha512", - "/home/jgcodes/.nuget/packages/microsoft.aspnetcore.app.ref/6.0.16/microsoft.aspnetcore.app.ref.6.0.16.nupkg.sha512", - "/home/jgcodes/.nuget/packages/microsoft.aspnetcore.app.runtime.win-x64/6.0.16/microsoft.aspnetcore.app.runtime.win-x64.6.0.16.nupkg.sha512", - "/home/jgcodes/.nuget/packages/microsoft.aspnetcore.app.runtime.linux-x64/6.0.16/microsoft.aspnetcore.app.runtime.linux-x64.6.0.16.nupkg.sha512", - "/home/jgcodes/.nuget/packages/microsoft.aspnetcore.app.runtime.osx-x64/6.0.16/microsoft.aspnetcore.app.runtime.osx-x64.6.0.16.nupkg.sha512", - "/home/jgcodes/.nuget/packages/microsoft.netcore.app.host.win-x64/6.0.16/microsoft.netcore.app.host.win-x64.6.0.16.nupkg.sha512", - "/home/jgcodes/.nuget/packages/microsoft.netcore.app.host.linux-x64/6.0.16/microsoft.netcore.app.host.linux-x64.6.0.16.nupkg.sha512", - "/home/jgcodes/.nuget/packages/microsoft.netcore.app.host.osx-x64/6.0.16/microsoft.netcore.app.host.osx-x64.6.0.16.nupkg.sha512" - ], - "logs": [] -} \ No newline at end of file diff --git a/CSZeroMQ/obj/project.packagespec.json b/CSZeroMQ/obj/project.packagespec.json deleted file mode 100644 index 2eb6fb2..0000000 --- a/CSZeroMQ/obj/project.packagespec.json +++ /dev/null @@ -1 +0,0 @@ -"restore":{"projectUniqueName":"/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/CSZeroMQ.csproj","projectName":"CSZeroMQ","projectPath":"/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/CSZeroMQ.csproj","outputPath":"/home/jgcodes/Documents/Code/C#/CSZeroMQ/CSZeroMQ/obj/","projectStyle":"PackageReference","originalTargetFrameworks":["net6.0"],"sources":{"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net6.0":{"targetAlias":"net6.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]}}"frameworks":{"net6.0":{"targetAlias":"net6.0","imports":["net461","net462","net47","net471","net472","net48","net481"],"assetTargetFallback":true,"warn":true,"downloadDependencies":[{"name":"Microsoft.AspNetCore.App.Ref","version":"[6.0.16, 6.0.16]"},{"name":"Microsoft.AspNetCore.App.Runtime.linux-x64","version":"[6.0.16, 6.0.16]"},{"name":"Microsoft.AspNetCore.App.Runtime.osx-x64","version":"[6.0.16, 6.0.16]"},{"name":"Microsoft.AspNetCore.App.Runtime.win-x64","version":"[6.0.16, 6.0.16]"},{"name":"Microsoft.NETCore.App.Host.linux-x64","version":"[6.0.16, 6.0.16]"},{"name":"Microsoft.NETCore.App.Host.osx-x64","version":"[6.0.16, 6.0.16]"},{"name":"Microsoft.NETCore.App.Host.win-x64","version":"[6.0.16, 6.0.16]"},{"name":"Microsoft.NETCore.App.Runtime.linux-x64","version":"[6.0.16, 6.0.16]"},{"name":"Microsoft.NETCore.App.Runtime.osx-x64","version":"[6.0.16, 6.0.16]"},{"name":"Microsoft.NETCore.App.Runtime.win-x64","version":"[6.0.16, 6.0.16]"}],"frameworkReferences":{"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"/usr/share/dotnet/sdk/7.0.105/RuntimeIdentifierGraph.json"}}"runtimes":{"linux-x64":{"#import":[]},"osx-x64":{"#import":[]},"win10-x64":{"#import":[]}} \ No newline at end of file diff --git a/CSZeroMQ/obj/rider.project.restore.info b/CSZeroMQ/obj/rider.project.restore.info deleted file mode 100644 index ebde09b..0000000 --- a/CSZeroMQ/obj/rider.project.restore.info +++ /dev/null @@ -1 +0,0 @@ -16864101844461409 \ No newline at end of file diff --git a/CSZeroMQ/runtimes/linux-x64/native/libzmq.so b/CSZeroMQ/runtimes/linux-x64/native/libzmq.so deleted file mode 100644 index 91881ef..0000000 Binary files a/CSZeroMQ/runtimes/linux-x64/native/libzmq.so and /dev/null differ diff --git a/CSZeroMQ/runtimes/linux_x64/native/libzmq.so b/CSZeroMQ/runtimes/linux_x64/native/libzmq.so new file mode 100644 index 0000000..df4a242 Binary files /dev/null and b/CSZeroMQ/runtimes/linux_x64/native/libzmq.so differ diff --git a/CSZeroMQ/runtimes/osx-x64/native/libzmq.dylib b/CSZeroMQ/runtimes/osx_x64/native/libzmq.dylib similarity index 100% rename from CSZeroMQ/runtimes/osx-x64/native/libzmq.dylib rename to CSZeroMQ/runtimes/osx_x64/native/libzmq.dylib diff --git a/CSZeroMQ/runtimes/win10-x64/native/libzmq.dll b/CSZeroMQ/runtimes/win10-x64/native/libzmq.dll deleted file mode 100644 index cf8fa79..0000000 Binary files a/CSZeroMQ/runtimes/win10-x64/native/libzmq.dll and /dev/null differ diff --git a/CSZeroMQ/runtimes/win10_x64/native/libzmq-v143-mt-4_3_5.dll b/CSZeroMQ/runtimes/win10_x64/native/libzmq-v143-mt-4_3_5.dll new file mode 100644 index 0000000..7cec6fb Binary files /dev/null and b/CSZeroMQ/runtimes/win10_x64/native/libzmq-v143-mt-4_3_5.dll differ diff --git a/CSZeroMQPublisher/CSZeroMQPublisher.csproj b/CSZeroMQPublisher/CSZeroMQPublisher.csproj new file mode 100644 index 0000000..299aaa6 --- /dev/null +++ b/CSZeroMQPublisher/CSZeroMQPublisher.csproj @@ -0,0 +1,22 @@ + + + + Exe + net6.0 + enable + enable + + + + ..\bin\Debug\ + + + + ..\bin\Release\ + + + + + + + diff --git a/CSZeroMQPublisher/Program.cs b/CSZeroMQPublisher/Program.cs new file mode 100644 index 0000000..2f22c1d --- /dev/null +++ b/CSZeroMQPublisher/Program.cs @@ -0,0 +1,27 @@ +using System.Text; +using CSZeroMQ; +using CSZeroMQ.Constants; + +namespace CSZeroMQPublisher +{ + internal static class PubProgram + { + private static void Main(string[] args) + { + const string uri = "ipc://ipx_example.ipc"; + ZMQContext context = new ZMQContext(); + ZMQSocket pubSocket = new ZMQSocket(SocketType.Pub, context); + + pubSocket.Bind(uri); + Console.WriteLine("Publisher bound to " + uri); + + while (true) + { + ReadOnlySpan msg = Encoding.UTF8.GetBytes("Hello world"); + pubSocket.Send(msg); + Console.WriteLine("Sent: Hello world"); + Thread.Sleep(1000); // Send a message every second + } + } + } +} \ No newline at end of file diff --git a/CSZeroMQSubscriber/CSZeroMQSubscriber.csproj b/CSZeroMQSubscriber/CSZeroMQSubscriber.csproj new file mode 100644 index 0000000..299aaa6 --- /dev/null +++ b/CSZeroMQSubscriber/CSZeroMQSubscriber.csproj @@ -0,0 +1,22 @@ + + + + Exe + net6.0 + enable + enable + + + + ..\bin\Debug\ + + + + ..\bin\Release\ + + + + + + + diff --git a/CSZeroMQSubscriber/Program.cs b/CSZeroMQSubscriber/Program.cs new file mode 100644 index 0000000..b3bde2a --- /dev/null +++ b/CSZeroMQSubscriber/Program.cs @@ -0,0 +1,30 @@ +using System.Text; +using CSZeroMQ; +using CSZeroMQ.Constants; + +namespace CSZeroMQSubscriber +{ + internal static class SubProgram + { + private static void Main(string[] args) + { + const string uri = "ipc://ipx_example.ipc"; + ZMQContext context = new ZMQContext(); + ZMQSocket subSocket = new ZMQSocket(SocketType.Sub, context); + + subSocket.Connect(uri); + subSocket.SetOption(SocketOptionString.Subscribe, ""); // Subscribe to all messages + Console.WriteLine("Subscriber connected to " + uri); + + while (true) + { + var zmqMsg = subSocket.ReceiveMsg(); + if (zmqMsg != null) + { + var decodedString = Encoding.UTF8.GetString(zmqMsg.Span); + Console.WriteLine("Received: " + decodedString); + } + } + } + } +} \ No newline at end of file diff --git a/Native/Headers/zmq.h b/Native/Headers/zmq.h index d05659f..6520b07 100644 --- a/Native/Headers/zmq.h +++ b/Native/Headers/zmq.h @@ -1,32 +1,5 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . - - ************************************************************************* +/* SPDX-License-Identifier: MPL-2.0 */ +/* ************************************************************************* NOTE to contributors. This file comprises the principal public contract for ZeroMQ API users. Any change to this file supplied in a stable release SHOULD not break existing applications. @@ -41,7 +14,7 @@ /* Version macros for compile-time API version detection */ #define ZMQ_VERSION_MAJOR 4 #define ZMQ_VERSION_MINOR 3 -#define ZMQ_VERSION_PATCH 4 +#define ZMQ_VERSION_PATCH 5 #define ZMQ_MAKE_VERSION(major, minor, patch) \ ((major) *10000 + (minor) *100 + (patch)) @@ -57,23 +30,11 @@ extern "C" { #endif #include #include -#if defined _WIN32 -// Set target version to Windows Server 2008, Windows Vista or higher. -// Windows XP (0x0501) is supported but without client & server socket types. -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 -#endif - -#ifdef __MINGW32__ -// Require Windows XP or higher with MinGW for getaddrinfo(). -#if (_WIN32_WINNT >= 0x0501) -#else -#error You need at least Windows XP target -#endif -#endif -#endif /* Handle DSO symbol visibility */ +#if defined ZMQ_NO_EXPORT +#define ZMQ_EXPORT +#else #if defined _WIN32 #if defined ZMQ_STATIC #define ZMQ_EXPORT @@ -91,6 +52,7 @@ extern "C" { #define ZMQ_EXPORT #endif #endif +#endif /* Define integer types needed for event interface */ #define ZMQ_DEFINED_STDINT 1 @@ -116,6 +78,11 @@ typedef unsigned __int8 uint8_t; #include #endif +#if !defined _WIN32 +// needed for sigset_t definition in zmq_ppoll +#include +#endif + // 32-bit AIX's pollfd struct members are called reqevents and rtnevents so it // defines compatibility macros for them. Need to include that header first to // stop build failures since zmq_pollset_t defines them as events and revents. @@ -264,7 +231,7 @@ typedef struct zmq_msg_t #endif } zmq_msg_t; -typedef void(zmq_free_fn) (void *data_, void *hint_); +typedef void (zmq_free_fn) (void *data_, void *hint_); ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg_); ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_); @@ -572,7 +539,7 @@ zmq_z85_encode (char *dest_, const uint8_t *data_, size_t size_); /* Decode data with Z85 encoding. Returns decoded data */ ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest_, const char *string_); -/* Generate z85-encoded public and private keypair with tweetnacl/libsodium. */ +/* Generate z85-encoded public and private keypair with libsodium. */ /* Returns 0 on success. */ ZMQ_EXPORT int zmq_curve_keypair (char *z85_public_key_, char *z85_secret_key_); @@ -598,7 +565,7 @@ ZMQ_EXPORT void zmq_atomic_counter_destroy (void **counter_p_); #define ZMQ_HAVE_TIMERS -typedef void(zmq_timer_fn) (int timer_id, void *arg); +typedef void (zmq_timer_fn) (int timer_id, void *arg); ZMQ_EXPORT void *zmq_timers_new (void); ZMQ_EXPORT int zmq_timers_destroy (void **timers_p); @@ -635,7 +602,7 @@ ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_); /* Sleeps for specified number of seconds. */ ZMQ_EXPORT void zmq_sleep (int seconds_); -typedef void(zmq_thread_fn) (void *); +typedef void (zmq_thread_fn) (void *); /* Start a thread. Returns a handle to the thread. */ ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn *func_, void *arg_); @@ -683,11 +650,30 @@ ZMQ_EXPORT void zmq_threadclose (void *thread_); #define ZMQ_HELLO_MSG 110 #define ZMQ_DISCONNECT_MSG 111 #define ZMQ_PRIORITY 112 +#define ZMQ_BUSY_POLL 113 +#define ZMQ_HICCUP_MSG 114 +#define ZMQ_XSUB_VERBOSE_UNSUBSCRIBE 115 +#define ZMQ_TOPICS_COUNT 116 +#define ZMQ_NORM_MODE 117 +#define ZMQ_NORM_UNICAST_NACK 118 +#define ZMQ_NORM_BUFFER_SIZE 119 +#define ZMQ_NORM_SEGMENT_SIZE 120 +#define ZMQ_NORM_BLOCK_SIZE 121 +#define ZMQ_NORM_NUM_PARITY 122 +#define ZMQ_NORM_NUM_AUTOPARITY 123 +#define ZMQ_NORM_PUSH 124 + +/* DRAFT ZMQ_NORM_MODE options */ +#define ZMQ_NORM_FIXED 0 +#define ZMQ_NORM_CC 1 +#define ZMQ_NORM_CCL 2 +#define ZMQ_NORM_CCE 3 +#define ZMQ_NORM_CCE_ECNONLY 4 /* DRAFT ZMQ_RECONNECT_STOP options */ #define ZMQ_RECONNECT_STOP_CONN_REFUSED 0x1 #define ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED 0x2 -#define ZMQ_RECONNECT_STOP_AFTER_DISCONNECT 0x3 +#define ZMQ_RECONNECT_STOP_AFTER_DISCONNECT 0x4 /* DRAFT Context options */ #define ZMQ_ZERO_COPY_RECV 10 @@ -776,6 +762,19 @@ ZMQ_EXPORT int zmq_socket_monitor_versioned ( void *s_, const char *addr_, uint64_t events_, int event_version_, int type_); ZMQ_EXPORT int zmq_socket_monitor_pipes_stats (void *s); +#if !defined _WIN32 +ZMQ_EXPORT int zmq_ppoll (zmq_pollitem_t *items_, + int nitems_, + long timeout_, + const sigset_t *sigmask_); +#else +// Windows has no sigset_t +ZMQ_EXPORT int zmq_ppoll (zmq_pollitem_t *items_, + int nitems_, + long timeout_, + const void *sigmask_); +#endif + #endif // ZMQ_BUILD_DRAFT_API diff --git a/Native/Headers/zmq_utils.h b/Native/Headers/zmq_utils.h new file mode 100644 index 0000000..c409406 --- /dev/null +++ b/Native/Headers/zmq_utils.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: MPL-2.0 */ + +/* This file is deprecated, and all its functionality provided by zmq.h */ +/* Note that -Wpedantic compilation requires GCC to avoid using its custom + extensions such as #warning, hence the trick below. Also, pragmas for + warnings or other messages are not standard, not portable, and not all + compilers even have an equivalent concept. + So in the worst case, this include file is treated as silently empty. */ + +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) \ + || defined(_MSC_VER) +#if defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic push +#pragma GCC diagnostic warning "-Wcpp" +#pragma GCC diagnostic ignored "-Werror" +#pragma GCC diagnostic ignored "-Wall" +#endif +#pragma message( \ + "Warning: zmq_utils.h is deprecated. All its functionality is provided by zmq.h.") +#if defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic pop +#endif +#endif