diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index d90ae22..d3c25cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,171 @@ -# ignore files and folders intended for local use only -**/bin -**/obj +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files *.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets +!packages/*/build/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# Enable nuget.exe in the .nuget folder (though normally executables are not tracked) +!.nuget/NuGet.exe + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +# =================================================== +# Exclude F# project specific directories and files +# =================================================== + +# NuGet Packages Directory +packages/ + +# Generated documentation folder +docs/output/ + +# Temp folder used for publishing docs +temp/ + +# Test results produced by build +TestResults.xml diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config new file mode 100644 index 0000000..67f8ea0 --- /dev/null +++ b/.nuget/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe new file mode 100644 index 0000000..2c93698 Binary files /dev/null and b/.nuget/NuGet.exe differ diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets new file mode 100644 index 0000000..83fe906 --- /dev/null +++ b/.nuget/NuGet.targets @@ -0,0 +1,136 @@ + + + + $(MSBuildProjectDirectory)\..\ + + + false + + + false + + + true + + + false + + + + + + + + + + + $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) + $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) + + + + + $(SolutionDir).nuget + packages.config + + + + + $(NuGetToolsPath)\NuGet.exe + @(PackageSource) + + "$(NuGetExePath)" + mono --runtime=v4.0.30319 $(NuGetExePath) + + $(TargetDir.Trim('\\')) + + -RequireConsent + -NonInteractive + + "$(SolutionDir) " + "$(SolutionDir)" + + + $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) + $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols + + + + RestorePackages; + $(BuildDependsOn); + + + + + $(BuildDependsOn); + BuildPackage; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.nuget/packages.config b/.nuget/packages.config new file mode 100644 index 0000000..eb41749 --- /dev/null +++ b/.nuget/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt index 478c496..68a49da 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,201 +1,24 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. \ No newline at end of file +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/README.md b/README.md index 0db8b8d..6f0e061 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,23 @@ - -fs-zmq -====== ----------------------------------------------------------------------------- - -### An F# binding for the ZeroMQ light-weight messaging kernel. - -**This project is at an early stage of development.** Its stable, but requires more testing and polishing. - -It provides a complete binding to the 3.x branch of ZeroMQ. This library is primarily designed to be consumed from F#. However, where possible, the API has been designed to appear "friendly" when consumed by other .NET languages (C#, et aliam). - -More details to follow. - ----------------------------------------------------------------------------- -###### Copyright © Paulmichael Blasucci. All rights reserved. + +fszmq +======================= + +---------------------------------------------------------------------------- + +### An F# binding for the ZeroMQ light-weight messaging kernel. + +More details to follow. + +---------------------------------------------------------------------------- +###### Copyright © Paulmichael Blasucci. All rights reserved. diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md new file mode 100644 index 0000000..297d7fd --- /dev/null +++ b/RELEASE_NOTES.md @@ -0,0 +1 @@ +* 4.0.1 - Enhanced solution structure (tests, deployment, docs, et cetera); Upgraded to latest libzmq.dll diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000..b72585b --- /dev/null +++ b/build.cmd @@ -0,0 +1,6 @@ +@echo off +if not exist packages\FAKE\tools\Fake.exe ( + .nuget\nuget.exe install FAKE -OutputDirectory packages -ExcludeVersion -Prerelease +) +packages\FAKE\tools\FAKE.exe build.fsx %* +pause diff --git a/build.fsx b/build.fsx new file mode 100644 index 0000000..64eab12 --- /dev/null +++ b/build.fsx @@ -0,0 +1,187 @@ +// -------------------------------------------------------------------------------------- +// FAKE build script +// -------------------------------------------------------------------------------------- + +#r @"packages/FAKE/tools/FakeLib.dll" +open Fake +open Fake.Git +open Fake.AssemblyInfoFile +open Fake.ReleaseNotesHelper +open System + +// -------------------------------------------------------------------------------------- +// START TODO: Provide project-specific details below +// -------------------------------------------------------------------------------------- + +// Information about the project are used +// - for version and project name in generated AssemblyInfo file +// - by the generated NuGet package +// - to run tests and to publish documentation on GitHub gh-pages +// - for documentation, you also need to edit info in "docs/tools/generate.fsx" + +// The name of the project +// (used by attributes in AssemblyInfo, name of a NuGet package and directory in 'src') +let project = "fszmq" + +// Short summary of the project +// (used as description in AssemblyInfo and as a short summary for NuGet package) +let summary = "An Apache-licenced F# binding for the ØMQ concurrent programming library." + +// Longer description of the project +// (used as a description for NuGet package; line breaks are automatically cleaned up) +let description = """An Apache-licenced F# binding for the ØMQ concurrent programming library.""" + +// List of author names (for NuGet package) +let authors = [ "Paulmichael Blasucci" ] +// Tags for your project (for NuGet package) +let tags = "F# fsharp zeromq zmq 0MQ concurrent distributed messaging transport" + +// File system information +// (.sln and .Tests.sln are built during the building) +let solutionFile = "fszmq" +// Pattern specifying assemblies to be tested using NUnit +let testAssemblies = ["tests/*/bin/*/fszmq*tests*.dll"] + +// Git configuration (used for publishing documentation in gh-pages branch) +// The profile where the project is posted +let gitHome = "https://github.com/pblasucci" +// The name of the project on GitHub +let gitName = "fszmq" + +// -------------------------------------------------------------------------------------- +// END TODO: The rest of the file includes standard build steps +// -------------------------------------------------------------------------------------- + +// Read additional information from the release notes document +Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ +let release = parseReleaseNotes (IO.File.ReadAllLines "RELEASE_NOTES.md") + +// Generate assembly info files with the right version & up-to-date information +Target "AssemblyInfo" (fun _ -> + let fileName = "src/" + project + "/AssemblyInfo.fs" + CreateFSharpAssemblyInfo fileName + [ Attribute.Title project + Attribute.Product project + Attribute.Description summary + Attribute.Version release.AssemblyVersion + Attribute.FileVersion release.AssemblyVersion ] +) + +// -------------------------------------------------------------------------------------- +// Clean build results & restore NuGet packages + +Target "RestorePackages" (fun _ -> + !! "./**/packages.config" + |> Seq.iter (RestorePackage (fun p -> { p with ToolPath = "./.nuget/NuGet.exe" })) +) + +Target "Clean" (fun _ -> + CleanDirs ["bin"; "temp"] +) + +Target "CleanDocs" (fun _ -> + CleanDirs ["docs/output"] +) + +// -------------------------------------------------------------------------------------- +// Build library & test project + +Target "Build" (fun _ -> + { BaseDirectories = [__SOURCE_DIRECTORY__] + Includes = [ solutionFile + ".sln" + solutionFile + ".Tests.sln" ] + Excludes = [] } + |> Scan + |> MSBuildRelease "" "Rebuild" + |> ignore +) + +// -------------------------------------------------------------------------------------- +// Run the unit tests using test runner & kill test runner when complete + +Target "RunTests" (fun _ -> + let xunitVersion = GetPackageVersion "packages" "xunit.runners" + let xunitPath = sprintf "packages/xunit.runners.%s/tools/xunit.console.clr4.exe" xunitVersion + { BaseDirectories = [__SOURCE_DIRECTORY__] + Includes = testAssemblies + Excludes = [] } + |> Scan + |> xUnit (fun p -> + { p with + ToolPath = xunitPath + ShadowCopy = true + TimeOut = TimeSpan.FromMinutes 20. + OutputDir = @".\bin\" + HtmlOutput = true }) +) + +// -------------------------------------------------------------------------------------- +// Build a NuGet package + +Target "NuGet" (fun _ -> + // Format the description to fit on a single line (remove \r\n and double-spaces) + let description = description.Replace("\r", "") + .Replace("\n", "") + .Replace(" ", " ") + let nugetPath = ".nuget/nuget.exe" + NuGet (fun p -> + { p with + Authors = authors + Project = project + Summary = summary + Description = description + Version = release.NugetVersion + ReleaseNotes = String.Join(Environment.NewLine, release.Notes) + Tags = tags + OutputPath = "bin" + ToolPath = nugetPath + AccessKey = getBuildParamOrDefault "nugetkey" "" + Publish = hasBuildParam "nugetkey" + Dependencies = [] }) + ("nuget/" + project + ".nuspec") +) + +// -------------------------------------------------------------------------------------- +// Generate the documentation + +Target "GenerateDocs" (fun _ -> + executeFSIWithArgs "docs/tools" "generate.fsx" ["--define:RELEASE"] [] |> ignore +) + +// -------------------------------------------------------------------------------------- +// Release Scripts + +Target "ReleaseDocs" (fun _ -> + let ghPages = "gh-pages" + let ghPagesLocal = "temp/gh-pages" + Repository.clone "temp" (gitHome + "/" + gitName + ".git") ghPages + Branches.checkoutBranch ghPagesLocal ghPages + CopyRecursive "docs/output" ghPagesLocal true |> printfn "%A" + CommandHelper.runSimpleGitCommand ghPagesLocal "add ." |> printfn "%s" + let cmd = sprintf """commit -a -m "Update generated documentation for version %s""" release.NugetVersion + CommandHelper.runSimpleGitCommand ghPagesLocal cmd |> printfn "%s" + Branches.push ghPagesLocal +) + +Target "Release" DoNothing + +// -------------------------------------------------------------------------------------- +// Run all targets by default. Invoke 'build ' to override + +Target "All" DoNothing + +"Clean" + ==> "RestorePackages" + ==> "AssemblyInfo" + ==> "Build" + ==> "RunTests" + ==> "All" + +"All" + ==> "CleanDocs" + ==> "GenerateDocs" + ==> "ReleaseDocs" + ==> "NuGet" + ==> "Release" + +RunTargetOrDefault "All" diff --git a/deploy.cmd b/deploy.cmd deleted file mode 100644 index ad64489..0000000 --- a/deploy.cmd +++ /dev/null @@ -1,19 +0,0 @@ -REM ----------------------------------------------------------------------- -REM Copyright (c) Paulmichael Blasucci. -REM -REM This source code is subject to terms and conditions of the Apache -REM License, Version 2.0. A copy of the license can be found in the -REM License.html file at the root of this distribution. -REM -REM By using this source code in any fashion, you are agreeing to be bound -REM by the terms of the Apache License, Version 2.0. -REM -REM You must not remove this notice, or any other, from this software. -REM ----------------------------------------------------------------------- - -REM this script assumes fsi.exe is in the PATH evironment variable - -set NUGET="C:\Program Files (x86)\NuGet Bootstrap\nuget.exe" -set ROOT=D:\working\fs-zmq - -fsi deploy.fsx -- %ROOT% %NUGET% diff --git a/deploy.fsx b/deploy.fsx deleted file mode 100644 index 41fe938..0000000 --- a/deploy.fsx +++ /dev/null @@ -1,94 +0,0 @@ -(*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*) -open System - -#r "System.IO.Compression" -#r "System.IO.Compression.FileSystem.dll" -open System.IO -open System.IO.Compression - -type System.IO.DirectoryInfo with - member D.MakePath(fileName) = Path.Combine(D.FullName,fileName) - member D.MakePath(info:FileInfo) = D.MakePath(info.Name) - -type System.IO.FileInfo with - member F.CopyTo(info:DirectoryInfo) = F.CopyTo(info.MakePath(F)) - -// get input arguments -let rootDir,nuget = - let emdash = fsi.CommandLineArgs |> Array.findIndex ((=) "--") - fsi.CommandLineArgs.[emdash + 1],fsi.CommandLineArgs.[emdash + 2] - -// pathing information -let [] GITIGNORE = @".gitignore" -let [] ARCHIVEXT = @".zip" -let [] NUGETSPEC = @"fszmq.nuspec" -let [] NUPACKEXT = @".nupkg" -let [] ZEROMQLIB = @"libzmq.dll" -let [] FSZMQEXTS = @"fszmq.*" - -let libDir = DirectoryInfo(Path.Combine(rootDir,"zeromq")) -let pkgDir = DirectoryInfo(Path.Combine(rootDir,"nuget" )) -let binDir = DirectoryInfo(Path.Combine(rootDir,"bin" )) -let outDir = DirectoryInfo(Path.Combine(rootDir,"deploy")) - -// remove existing artifacts from deployment folder -outDir.GetDirectories() - |> Array.iter (fun d -> d.Delete(true)) - -outDir.GetFiles() - |> Array.filter (fun f -> f.Name <> GITIGNORE) - |> Array.iter (fun f -> f.Delete()) - -// copy intermediate files to deployment folder -binDir.GetFiles(FSZMQEXTS) - |> Array.append (libDir.GetFiles ZEROMQLIB) - |> Array.iter (fun f -> f.CopyTo(outDir) |> ignore) - -// compile nuget package -open System.Diagnostics - -let package() = - let nugetArgs = - sprintf "pack %s -OutputDirectory %s -NonInteractive -Verbosity quiet" - (pkgDir.MakePath NUGETSPEC) - (outDir.FullName ) - let startInfo = ProcessStartInfo(nuget,nugetArgs,UseShellExecute=false) - use nugetProc = Process.Start(startInfo) - nugetProc.WaitForExit() - -package() - -// compress intermediate files into archive -let archive() = - let archiveList = outDir.GetFiles("*" + NUPACKEXT) - |> Array.map (fun f -> f.FullName.Replace(NUPACKEXT - ,ARCHIVEXT)) - if Seq.length archiveList > 0 then - let archiveName = Seq.head archiveList - let sourceFiles = outDir.GetFiles() - |> Array.filter (fun f -> f.Extension <> GITIGNORE - && f.Extension <> NUPACKEXT - && f.Extension <> ARCHIVEXT) - use zip = ZipFile.Open(archiveName,ZipArchiveMode.Update) - for file in sourceFiles do - zip.CreateEntryFromFile(file.FullName,file.Name) |> ignore - -archive() - -// remove intermediate files from deployment folder -outDir.GetFiles() - |> Array.filter (fun f -> f.Extension <> GITIGNORE - && f.Extension <> NUPACKEXT - && f.Extension <> ARCHIVEXT) - |> Array.iter (fun f -> f.Delete()) diff --git a/deploy/.gitignore b/deploy/.gitignore deleted file mode 100644 index cf5ea9b..0000000 --- a/deploy/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# ignore deployment files, these are for local use only -*.* diff --git a/docs/content/index.fsx b/docs/content/index.fsx new file mode 100644 index 0000000..b22546e --- /dev/null +++ b/docs/content/index.fsx @@ -0,0 +1,70 @@ +(*** hide ***) +// This block of code is omitted in the generated HTML documentation. Use +// it to define helpers that you do not want to show in the documentation. +#I "../../bin" + +(** +F# Project Scaffold +=================== + +Documentation + +
+
+
+
+ The F# DataFrame library can be installed from NuGet: +
PM> Install-Package FSharp.ProjectTemplate
+
+
+
+
+ +F# project + +Example +------- + +Assume we loaded [Titanic data set](http://www.kaggle.com/c/titanic-gettingStarted) +into a data frame called `titanic` (the data frame has numerous columns including string +`Sex` and Boolean `Survived`). Now we can calculate the survival rates for males and females: + +*) +#r "FSharp.ProjectTemplate.dll" +open FSharp.ProjectTemplate + +Library.hello 0 +(** +Some more info + +Samples & documentation +----------------------- + +The library comes with comprehensible documentation. The tutorials and articles are +automatically generated from `*.fsx` files in [the samples folder][samples]. The API +reference is automatically generated from Markdown comments in the library implementation. + + * [Stuff](stuff.html) has more stuff + + * [API Reference](reference/index.html) contains automatically generated documentation for all types, modules + and functions in the library. This includes additional brief samples on using most of the + functions. + +Contributing and copyright +-------------------------- + +The project is hosted on [GitHub][gh] where you can [report issues][issues], fork +the project and submit pull requests. If you're adding new public API, please also +consider adding [samples][samples] that can be turned into a documentation. You might +also want to read [library design notes](design.html) to understand how it works. + +The library is available under **INSERT** license, which allows modification and +redistribution for both commercial and non-commercial purposes. For more information see the +[License file][license] in the GitHub repository. + + [samples]: https://github.com/fsharp/FSharp.ProjectScaffold/tree/master/samples + [gh]: https://github.com/fsharp/FSharp.ProjectScaffold + [issues]: https://github.com/fsharp/FSharp.ProjectScaffold/issues + [readme]: https://github.com/fsharp/FSharp.ProjectScaffold/blob/master/README.md + [license]: https://github.com/fsharp/FSharp.ProjectScaffold/blob/master/LICENSE.md +*) \ No newline at end of file diff --git a/docs/content/tutorial.fsx b/docs/content/tutorial.fsx new file mode 100644 index 0000000..a5ca244 --- /dev/null +++ b/docs/content/tutorial.fsx @@ -0,0 +1,19 @@ +(*** hide ***) +// This block of code is omitted in the generated HTML documentation. Use +// it to define helpers that you do not want to show in the documentation. +#I "../../bin" + +(** +Introducing your project +======================== + +Say more + +*) +#r "FSharp.ProjectTemplate.dll" +open FSharp.ProjectTemplate + +Library.hello 0 +(** +Some more info +*) diff --git a/nuget/zmq_logo.png b/docs/files/img/zmq_logo.png similarity index 100% rename from nuget/zmq_logo.png rename to docs/files/img/zmq_logo.png diff --git a/docs/tools/generate.fsx b/docs/tools/generate.fsx new file mode 100644 index 0000000..0554fba --- /dev/null +++ b/docs/tools/generate.fsx @@ -0,0 +1,86 @@ +// -------------------------------------------------------------------------------------- +// Builds the documentation from `.fsx` and `.md` files in the 'docs/content' directory +// (the generated documentation is stored in the 'docs/output' directory) +// -------------------------------------------------------------------------------------- + +// Binaries that have XML documentation (in a corresponding generated XML file) +let referenceBinaries = [ "fszmq.dll" ] +// Web site location for the generated documentation +let website = "http://pblasucci.github.io/fszmq" + +// Specify more information about your project +let info = + [ "project-name", "fszmq" + "project-author", "Paulmichael Blasucci" + "project-summary", "An Apache-licenced F# binding for the ØMQ concurrent programming library." + "project-github", "http://github.com/pblasucci/fszmq" + "project-nuget", "http://nuget.com/packages/fszmq" ] + +// -------------------------------------------------------------------------------------- +// For typical project, no changes are needed below +// -------------------------------------------------------------------------------------- + +#I "../../packages/FSharp.Formatting.2.1.6/lib/net40" +#I "../../packages/RazorEngine.3.3.0/lib/net40/" +#r "../../packages/Microsoft.AspNet.Razor.2.0.30506.0/lib/net40/System.Web.Razor.dll" +#r "../../packages/FAKE/tools/FakeLib.dll" +#r "RazorEngine.dll" +#r "FSharp.Literate.dll" +#r "FSharp.CodeFormat.dll" +#r "FSharp.MetadataFormat.dll" +open Fake +open System.IO +open Fake.FileHelper +open FSharp.Literate +open FSharp.MetadataFormat + +// When called from 'build.fsx', use the public project URL as +// otherwise, use the current 'output' directory. +#if RELEASE +let root = website +#else +let root = "file://" + (__SOURCE_DIRECTORY__ @@ "../output") +#endif + +// Paths with template/source/output locations +let bin = __SOURCE_DIRECTORY__ @@ "../../bin" +let content = __SOURCE_DIRECTORY__ @@ "../content" +let output = __SOURCE_DIRECTORY__ @@ "../output" +let files = __SOURCE_DIRECTORY__ @@ "../files" +let templates = __SOURCE_DIRECTORY__ @@ "templates" +let formatting = __SOURCE_DIRECTORY__ @@ "../../packages/FSharp.Formatting.2.1.6/" +let docTemplate = formatting @@ "templates/docpage.cshtml" + +// Where to look for *.csproj templates (in this order) +let layoutRoots = + [ templates; formatting @@ "templates" + formatting @@ "templates/reference" ] + +// Copy static files and CSS + JS from F# Formatting +let copyFiles () = + CopyRecursive files output true |> Log "Copying file: " + ensureDirectory (output @@ "content") + CopyRecursive (formatting @@ "content") (output @@ "content") true + |> Log "Copying styles and scripts: " + +// Build API reference from XML comments +let buildReference () = + CleanDir (output @@ "reference") + for lib in referenceBinaries do + MetadataFormat.Generate + ( bin @@ lib, output @@ "reference", layoutRoots, + parameters = ("root", root)::info ) + +// Build documentation from `fsx` and `md` files in `docs/content` +let buildDocumentation () = + let subdirs = Directory.EnumerateDirectories(content, "*", SearchOption.AllDirectories) + for dir in Seq.append [content] subdirs do + let sub = if dir.Length > content.Length then dir.Substring(content.Length + 1) else "." + Literate.ProcessDirectory + ( dir, docTemplate, output @@ sub, replacements = ("root", root)::info, + layoutRoots = layoutRoots ) + +// Generate +copyFiles() +buildDocumentation() +buildReference() diff --git a/docs/tools/packages.config b/docs/tools/packages.config new file mode 100644 index 0000000..26f77f2 --- /dev/null +++ b/docs/tools/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/docs/tools/templates/template.cshtml b/docs/tools/templates/template.cshtml new file mode 100644 index 0000000..b409491 --- /dev/null +++ b/docs/tools/templates/template.cshtml @@ -0,0 +1,58 @@ + + + + + @Title + + + + + + + + + + + + + + + +
+
+ +

@Properties["project-name"]

+
+
+
+
+ @RenderBody() +
+
+ +
+
+
+ Fork me on GitHub + + diff --git a/fszmq.compat.vb/fszmq.compat.vb.vbproj.user b/fszmq.compat.vb/fszmq.compat.vb.vbproj.user deleted file mode 100644 index 76fe5a5..0000000 --- a/fszmq.compat.vb/fszmq.compat.vb.vbproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - ProjectFiles - - \ No newline at end of file diff --git a/fszmq.inproc_throughput/App.config b/fszmq.inproc_throughput/App.config deleted file mode 100644 index c9bdc98..0000000 --- a/fszmq.inproc_throughput/App.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/fs-zmq.sln b/fszmq.sln similarity index 50% rename from fs-zmq.sln rename to fszmq.sln index 70e31c7..b156951 100644 --- a/fs-zmq.sln +++ b/fszmq.sln @@ -1,106 +1,146 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8E330EB0-BE55-4289-BF9B-38CA7B76BDFD}" - ProjectSection(SolutionItems) = preProject - deploy.cmd = deploy.cmd - deploy.fsx = deploy.fsx - nuget\fszmq.nuspec = nuget\fszmq.nuspec - nuget\Install.ps1 = nuget\Install.ps1 - README.md = README.md - nuget\zmq_logo.png = nuget\zmq_logo.png - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{FDB20CEC-1D7A-44EC-A45F-325FD5F24646}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compatability", "Compatability", "{E7E28F39-F8D1-4214-940C-C21035FBF8D8}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Performance", "Performance", "{35E68BE5-441C-4099-9EC4-A1F9CEE39E45}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "fszmq", "fszmq\fszmq.fsproj", "{D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fszmq.compat.cs", "fszmq.compat.cs\fszmq.compat.cs.csproj", "{E41153B1-DE3A-4808-8C29-5F21B11A2B47}" -EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "fszmq.compat.vb", "fszmq.compat.vb\fszmq.compat.vb.vbproj", "{9E64DAD3-2227-4AE8-88E3-295C42464C47}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "fszmq.perf.inproc_thr", "fszmq.inproc_throughput\fszmq.perf.inproc_thr.fsproj", "{267CB036-120C-4457-9193-65DAA3CB34AB}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|x64.ActiveCfg = Debug|x64 - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|x64.Build.0 = Debug|x64 - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|x86.ActiveCfg = Debug|x86 - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|x86.Build.0 = Debug|x86 - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|Any CPU.Build.0 = Release|Any CPU - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|x64.ActiveCfg = Release|x64 - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|x64.Build.0 = Release|x64 - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|x86.ActiveCfg = Release|x86 - {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|x86.Build.0 = Release|x86 - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|x64.ActiveCfg = Debug|x64 - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|x64.Build.0 = Debug|x64 - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|x86.ActiveCfg = Debug|x86 - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|x86.Build.0 = Debug|x86 - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Release|x64.ActiveCfg = Release|x64 - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Release|x64.Build.0 = Release|x64 - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Release|x86.ActiveCfg = Release|x86 - {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Release|x86.Build.0 = Release|x86 - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|x64.ActiveCfg = Debug|x64 - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|x64.Build.0 = Debug|x64 - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|x86.ActiveCfg = Debug|x86 - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|x86.Build.0 = Debug|x86 - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Release|x64.ActiveCfg = Release|x64 - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Release|x64.Build.0 = Release|x64 - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Release|x86.ActiveCfg = Release|x86 - {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Release|x86.Build.0 = Release|x86 - {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|x64.ActiveCfg = Debug|Any CPU - {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|x86.ActiveCfg = Debug|Any CPU - {267CB036-120C-4457-9193-65DAA3CB34AB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {267CB036-120C-4457-9193-65DAA3CB34AB}.Release|Any CPU.Build.0 = Release|Any CPU - {267CB036-120C-4457-9193-65DAA3CB34AB}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {267CB036-120C-4457-9193-65DAA3CB34AB}.Release|x64.ActiveCfg = Release|Any CPU - {267CB036-120C-4457-9193-65DAA3CB34AB}.Release|x86.ActiveCfg = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {E7E28F39-F8D1-4214-940C-C21035FBF8D8} = {FDB20CEC-1D7A-44EC-A45F-325FD5F24646} - {35E68BE5-441C-4099-9EC4-A1F9CEE39E45} = {FDB20CEC-1D7A-44EC-A45F-325FD5F24646} - {E41153B1-DE3A-4808-8C29-5F21B11A2B47} = {E7E28F39-F8D1-4214-940C-C21035FBF8D8} - {9E64DAD3-2227-4AE8-88E3-295C42464C47} = {E7E28F39-F8D1-4214-940C-C21035FBF8D8} - {267CB036-120C-4457-9193-65DAA3CB34AB} = {35E68BE5-441C-4099-9EC4-A1F9CEE39E45} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1F1B4F0F-2998-4D74-865B-9122611C2B14}" + ProjectSection(SolutionItems) = preProject + .nuget\NuGet.Config = .nuget\NuGet.Config + .nuget\NuGet.exe = .nuget\NuGet.exe + .nuget\NuGet.targets = .nuget\NuGet.targets + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{BF60BC93-E09B-4E5F-9D85-95A519479D54}" + ProjectSection(SolutionItems) = preProject + build.fsx = build.fsx + nuget\fszmq.nuspec = nuget\fszmq.nuspec + nuget\Install.ps1 = nuget\Install.ps1 + nuget\publish.cmd = nuget\publish.cmd + README.md = README.md + RELEASE_NOTES.md = RELEASE_NOTES.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{83F16175-43B1-4C90-A1EE-8E351C33435D}" + ProjectSection(SolutionItems) = preProject + docs\tools\generate.fsx = docs\tools\generate.fsx + docs\tools\templates\template.cshtml = docs\tools\templates\template.cshtml + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D5255-776D-4B61-85F9-73C37AA1FB9A}" + ProjectSection(SolutionItems) = preProject + docs\content\index.fsx = docs\content\index.fsx + docs\content\tutorial.fsx = docs\content\tutorial.fsx + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{ED8079DD-2B06-4030-9F0F-DC548F98E1C4}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "fszmq", "src\fszmq\fszmq.fsproj", "{D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "perf", "perf", "{0563B220-C3FD-4D3A-AF3A-04388C817AFE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "compat", "compat", "{7B19DF26-F8A5-49F1-B7E2-5CF4C5C6DD92}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fszmq.compat.cs", "tests\fszmq.compat.cs\fszmq.compat.cs.csproj", "{E41153B1-DE3A-4808-8C29-5F21B11A2B47}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "fszmq.compat.vb", "tests\fszmq.compat.vb\fszmq.compat.vb.vbproj", "{9E64DAD3-2227-4AE8-88E3-295C42464C47}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "fszmq.perf.inproc_thr", "tests\fszmq.inproc_throughput\fszmq.perf.inproc_thr.fsproj", "{267CB036-120C-4457-9193-65DAA3CB34AB}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "fszmq.tests", "tests\fszmq.tests\fszmq.tests.fsproj", "{9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|x64.ActiveCfg = Debug|Any CPU + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|x64.Build.0 = Debug|Any CPU + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|x86.ActiveCfg = Debug|Any CPU + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Debug|x86.Build.0 = Debug|Any CPU + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|Any CPU.Build.0 = Release|Any CPU + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|Mixed Platforms.Build.0 = Release|x86 + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|x64.ActiveCfg = Release|Any CPU + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|x64.Build.0 = Release|Any CPU + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|x86.ActiveCfg = Release|Any CPU + {D0F2CDEB-3D9C-4FE6-BEF9-27B9C7F0CF71}.Release|x86.Build.0 = Release|Any CPU + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|x64.ActiveCfg = Debug|Any CPU + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|x64.Build.0 = Debug|Any CPU + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|x86.ActiveCfg = Debug|Any CPU + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Debug|x86.Build.0 = Debug|Any CPU + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Release|Mixed Platforms.Build.0 = Release|x86 + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Release|x64.ActiveCfg = Release|Any CPU + {E41153B1-DE3A-4808-8C29-5F21B11A2B47}.Release|x86.ActiveCfg = Release|Any CPU + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|x64.ActiveCfg = Debug|Any CPU + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|x64.Build.0 = Debug|Any CPU + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|x86.ActiveCfg = Debug|Any CPU + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Debug|x86.Build.0 = Debug|Any CPU + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Release|Mixed Platforms.Build.0 = Release|x86 + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Release|x64.ActiveCfg = Release|Any CPU + {9E64DAD3-2227-4AE8-88E3-295C42464C47}.Release|x86.ActiveCfg = Release|Any CPU + {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|x64.ActiveCfg = Debug|x64 + {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|x64.Build.0 = Debug|x64 + {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|x86.ActiveCfg = Debug|x86 + {267CB036-120C-4457-9193-65DAA3CB34AB}.Debug|x86.Build.0 = Debug|x86 + {267CB036-120C-4457-9193-65DAA3CB34AB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {267CB036-120C-4457-9193-65DAA3CB34AB}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {267CB036-120C-4457-9193-65DAA3CB34AB}.Release|Mixed Platforms.Build.0 = Release|x86 + {267CB036-120C-4457-9193-65DAA3CB34AB}.Release|x64.ActiveCfg = Release|x64 + {267CB036-120C-4457-9193-65DAA3CB34AB}.Release|x86.ActiveCfg = Release|x86 + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Debug|x64.ActiveCfg = Debug|Any CPU + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Debug|x86.ActiveCfg = Debug|Any CPU + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Release|Any CPU.Build.0 = Release|Any CPU + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Release|x64.ActiveCfg = Release|Any CPU + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3}.Release|x86.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {83F16175-43B1-4C90-A1EE-8E351C33435D} = {A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1} + {8E6D5255-776D-4B61-85F9-73C37AA1FB9A} = {A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1} + {0563B220-C3FD-4D3A-AF3A-04388C817AFE} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4} + {7B19DF26-F8A5-49F1-B7E2-5CF4C5C6DD92} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4} + {9CA8C753-EB2E-40E5-BEAF-09F51B2601F3} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4} + {267CB036-120C-4457-9193-65DAA3CB34AB} = {0563B220-C3FD-4D3A-AF3A-04388C817AFE} + {E41153B1-DE3A-4808-8C29-5F21B11A2B47} = {7B19DF26-F8A5-49F1-B7E2-5CF4C5C6DD92} + {9E64DAD3-2227-4AE8-88E3-295C42464C47} = {7B19DF26-F8A5-49F1-B7E2-5CF4C5C6DD92} + EndGlobalSection +EndGlobal diff --git a/fszmq/AssemblyInfo.fs b/fszmq/AssemblyInfo.fs deleted file mode 100644 index c92b3ca..0000000 --- a/fszmq/AssemblyInfo.fs +++ /dev/null @@ -1,29 +0,0 @@ -(*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*) -namespace fszmq - -open System -open System.Reflection -open System.Runtime.CompilerServices -open System.Runtime.InteropServices - -[] -[] -[] -[] -[] -[] -[] -[] -[] -do((*nothing*)) diff --git a/lib/zeromq/include/zmq.h b/lib/zeromq/include/zmq.h new file mode 100644 index 0000000..8bb1e15 --- /dev/null +++ b/lib/zeromq/include/zmq.h @@ -0,0 +1,420 @@ +/* + Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file + + This file is part of 0MQ. + + 0MQ is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + 0MQ 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 . + + ************************************************************************* + NOTE to contributors. This file comprises the principal public contract + for ZeroMQ API users (along with zmq_utils.h). Any change to this file + supplied in a stable release SHOULD not break existing applications. + In practice this means that the value of constants must not change, and + that old values may not be reused for new constants. + ************************************************************************* +*/ + +#ifndef __ZMQ_H_INCLUDED__ +#define __ZMQ_H_INCLUDED__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined _WIN32_WCE +#include +#endif +#include +#include +#if defined _WIN32 +#include +#endif + +/* Handle DSO symbol visibility */ +#if defined _WIN32 +# if defined ZMQ_STATIC +# define ZMQ_EXPORT +# elif defined DLL_EXPORT +# define ZMQ_EXPORT __declspec(dllexport) +# else +# define ZMQ_EXPORT __declspec(dllimport) +# endif +#else +# if defined __SUNPRO_C || defined __SUNPRO_CC +# define ZMQ_EXPORT __global +# elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER +# define ZMQ_EXPORT __attribute__ ((visibility("default"))) +# else +# define ZMQ_EXPORT +# endif +#endif + +/* Define integer types needed for event interface */ +#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS +# include +#elif defined _MSC_VER && _MSC_VER < 1600 +# ifndef int32_t +typedef __int32 int32_t; +# endif +# ifndef uint16_t +typedef unsigned __int16 uint16_t; +# endif +# ifndef uint8_t +typedef unsigned __int8 uint8_t; +# endif +#else +# include +#endif + + +/******************************************************************************/ +/* 0MQ versioning support. */ +/******************************************************************************/ + +/* Version macros for compile-time API version detection */ +#define ZMQ_VERSION_MAJOR 4 +#define ZMQ_VERSION_MINOR 0 +#define ZMQ_VERSION_PATCH 1 + +#define ZMQ_MAKE_VERSION(major, minor, patch) \ + ((major) * 10000 + (minor) * 100 + (patch)) +#define ZMQ_VERSION \ + ZMQ_MAKE_VERSION(ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH) + +/* Run-time API version detection */ +ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch); + +/******************************************************************************/ +/* 0MQ errors. */ +/******************************************************************************/ + +/* A number random enough not to collide with different errno ranges on */ +/* different OSes. The assumption is that error_t is at least 32-bit type. */ +#define ZMQ_HAUSNUMERO 156384712 + +/* On Windows platform some of the standard POSIX errnos are not defined. */ +#ifndef ENOTSUP +#define ENOTSUP (ZMQ_HAUSNUMERO + 1) +#endif +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2) +#endif +#ifndef ENOBUFS +#define ENOBUFS (ZMQ_HAUSNUMERO + 3) +#endif +#ifndef ENETDOWN +#define ENETDOWN (ZMQ_HAUSNUMERO + 4) +#endif +#ifndef EADDRINUSE +#define EADDRINUSE (ZMQ_HAUSNUMERO + 5) +#endif +#ifndef EADDRNOTAVAIL +#define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6) +#endif +#ifndef ECONNREFUSED +#define ECONNREFUSED (ZMQ_HAUSNUMERO + 7) +#endif +#ifndef EINPROGRESS +#define EINPROGRESS (ZMQ_HAUSNUMERO + 8) +#endif +#ifndef ENOTSOCK +#define ENOTSOCK (ZMQ_HAUSNUMERO + 9) +#endif +#ifndef EMSGSIZE +#define EMSGSIZE (ZMQ_HAUSNUMERO + 10) +#endif +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT (ZMQ_HAUSNUMERO + 11) +#endif +#ifndef ENETUNREACH +#define ENETUNREACH (ZMQ_HAUSNUMERO + 12) +#endif +#ifndef ECONNABORTED +#define ECONNABORTED (ZMQ_HAUSNUMERO + 13) +#endif +#ifndef ECONNRESET +#define ECONNRESET (ZMQ_HAUSNUMERO + 14) +#endif +#ifndef ENOTCONN +#define ENOTCONN (ZMQ_HAUSNUMERO + 15) +#endif +#ifndef ETIMEDOUT +#define ETIMEDOUT (ZMQ_HAUSNUMERO + 16) +#endif +#ifndef EHOSTUNREACH +#define EHOSTUNREACH (ZMQ_HAUSNUMERO + 17) +#endif +#ifndef ENETRESET +#define ENETRESET (ZMQ_HAUSNUMERO + 18) +#endif + +/* Native 0MQ error codes. */ +#define EFSM (ZMQ_HAUSNUMERO + 51) +#define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 52) +#define ETERM (ZMQ_HAUSNUMERO + 53) +#define EMTHREAD (ZMQ_HAUSNUMERO + 54) + +/* This function retrieves the errno as it is known to 0MQ library. The goal */ +/* of this function is to make the code 100% portable, including where 0MQ */ +/* compiled with certain CRT library (on Windows) is linked to an */ +/* application that uses different CRT library. */ +ZMQ_EXPORT int zmq_errno (void); + +/* Resolves system errors and 0MQ errors to human-readable string. */ +ZMQ_EXPORT const char *zmq_strerror (int errnum); + +/******************************************************************************/ +/* 0MQ infrastructure (a.k.a. context) initialisation & termination. */ +/******************************************************************************/ + +/* New API */ +/* Context options */ +#define ZMQ_IO_THREADS 1 +#define ZMQ_MAX_SOCKETS 2 + +/* Default for new contexts */ +#define ZMQ_IO_THREADS_DFLT 1 +#define ZMQ_MAX_SOCKETS_DFLT 1024 + +ZMQ_EXPORT void *zmq_ctx_new (void); +ZMQ_EXPORT int zmq_ctx_term (void *context); +ZMQ_EXPORT int zmq_ctx_shutdown (void *ctx_); +ZMQ_EXPORT int zmq_ctx_set (void *context, int option, int optval); +ZMQ_EXPORT int zmq_ctx_get (void *context, int option); + +/* Old (legacy) API */ +ZMQ_EXPORT void *zmq_init (int io_threads); +ZMQ_EXPORT int zmq_term (void *context); +ZMQ_EXPORT int zmq_ctx_destroy (void *context); + + +/******************************************************************************/ +/* 0MQ message definition. */ +/******************************************************************************/ + +typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t; + +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); +ZMQ_EXPORT int zmq_msg_init_data (zmq_msg_t *msg, void *data, + size_t size, zmq_free_fn *ffn, void *hint); +ZMQ_EXPORT int zmq_msg_send (zmq_msg_t *msg, void *s, int flags); +ZMQ_EXPORT int zmq_msg_recv (zmq_msg_t *msg, void *s, int flags); +ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg); +ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src); +ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src); +ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg); +ZMQ_EXPORT size_t zmq_msg_size (zmq_msg_t *msg); +ZMQ_EXPORT int zmq_msg_more (zmq_msg_t *msg); +ZMQ_EXPORT int zmq_msg_get (zmq_msg_t *msg, int option); +ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval); + + +/******************************************************************************/ +/* 0MQ socket definition. */ +/******************************************************************************/ + +/* Socket types. */ +#define ZMQ_PAIR 0 +#define ZMQ_PUB 1 +#define ZMQ_SUB 2 +#define ZMQ_REQ 3 +#define ZMQ_REP 4 +#define ZMQ_DEALER 5 +#define ZMQ_ROUTER 6 +#define ZMQ_PULL 7 +#define ZMQ_PUSH 8 +#define ZMQ_XPUB 9 +#define ZMQ_XSUB 10 +#define ZMQ_STREAM 11 + +/* Deprecated aliases */ +#define ZMQ_XREQ ZMQ_DEALER +#define ZMQ_XREP ZMQ_ROUTER + +/* Socket options. */ +#define ZMQ_AFFINITY 4 +#define ZMQ_IDENTITY 5 +#define ZMQ_SUBSCRIBE 6 +#define ZMQ_UNSUBSCRIBE 7 +#define ZMQ_RATE 8 +#define ZMQ_RECOVERY_IVL 9 +#define ZMQ_SNDBUF 11 +#define ZMQ_RCVBUF 12 +#define ZMQ_RCVMORE 13 +#define ZMQ_FD 14 +#define ZMQ_EVENTS 15 +#define ZMQ_TYPE 16 +#define ZMQ_LINGER 17 +#define ZMQ_RECONNECT_IVL 18 +#define ZMQ_BACKLOG 19 +#define ZMQ_RECONNECT_IVL_MAX 21 +#define ZMQ_MAXMSGSIZE 22 +#define ZMQ_SNDHWM 23 +#define ZMQ_RCVHWM 24 +#define ZMQ_MULTICAST_HOPS 25 +#define ZMQ_RCVTIMEO 27 +#define ZMQ_SNDTIMEO 28 +#define ZMQ_LAST_ENDPOINT 32 +#define ZMQ_ROUTER_MANDATORY 33 +#define ZMQ_TCP_KEEPALIVE 34 +#define ZMQ_TCP_KEEPALIVE_CNT 35 +#define ZMQ_TCP_KEEPALIVE_IDLE 36 +#define ZMQ_TCP_KEEPALIVE_INTVL 37 +#define ZMQ_TCP_ACCEPT_FILTER 38 +#define ZMQ_IMMEDIATE 39 +#define ZMQ_XPUB_VERBOSE 40 +#define ZMQ_ROUTER_RAW 41 +#define ZMQ_IPV6 42 +#define ZMQ_MECHANISM 43 +#define ZMQ_PLAIN_SERVER 44 +#define ZMQ_PLAIN_USERNAME 45 +#define ZMQ_PLAIN_PASSWORD 46 +#define ZMQ_CURVE_SERVER 47 +#define ZMQ_CURVE_PUBLICKEY 48 +#define ZMQ_CURVE_SECRETKEY 49 +#define ZMQ_CURVE_SERVERKEY 50 +#define ZMQ_PROBE_ROUTER 51 +#define ZMQ_REQ_CORRELATE 52 +#define ZMQ_REQ_RELAXED 53 +#define ZMQ_CONFLATE 54 +#define ZMQ_ZAP_DOMAIN 55 + +/* Message options */ +#define ZMQ_MORE 1 + +/* Send/recv options. */ +#define ZMQ_DONTWAIT 1 +#define ZMQ_SNDMORE 2 + +/* Security mechanisms */ +#define ZMQ_NULL 0 +#define ZMQ_PLAIN 1 +#define ZMQ_CURVE 2 + +/* Deprecated options and aliases */ +#define ZMQ_IPV4ONLY 31 +#define ZMQ_DELAY_ATTACH_ON_CONNECT ZMQ_IMMEDIATE +#define ZMQ_NOBLOCK ZMQ_DONTWAIT +#define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY +#define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY + +/******************************************************************************/ +/* 0MQ socket events and monitoring */ +/******************************************************************************/ + +/* Socket transport events (tcp and ipc only) */ +#define ZMQ_EVENT_CONNECTED 1 +#define ZMQ_EVENT_CONNECT_DELAYED 2 +#define ZMQ_EVENT_CONNECT_RETRIED 4 + +#define ZMQ_EVENT_LISTENING 8 +#define ZMQ_EVENT_BIND_FAILED 16 + +#define ZMQ_EVENT_ACCEPTED 32 +#define ZMQ_EVENT_ACCEPT_FAILED 64 + +#define ZMQ_EVENT_CLOSED 128 +#define ZMQ_EVENT_CLOSE_FAILED 256 +#define ZMQ_EVENT_DISCONNECTED 512 +#define ZMQ_EVENT_MONITOR_STOPPED 1024 + +#define ZMQ_EVENT_ALL ( ZMQ_EVENT_CONNECTED | ZMQ_EVENT_CONNECT_DELAYED | \ + ZMQ_EVENT_CONNECT_RETRIED | ZMQ_EVENT_LISTENING | \ + ZMQ_EVENT_BIND_FAILED | ZMQ_EVENT_ACCEPTED | \ + ZMQ_EVENT_ACCEPT_FAILED | ZMQ_EVENT_CLOSED | \ + ZMQ_EVENT_CLOSE_FAILED | ZMQ_EVENT_DISCONNECTED | \ + ZMQ_EVENT_MONITOR_STOPPED) + +/* Socket event data */ +typedef struct { + uint16_t event; // id of the event as bitfield + int32_t value ; // value is either error code, fd or reconnect interval +} zmq_event_t; + +ZMQ_EXPORT void *zmq_socket (void *, int type); +ZMQ_EXPORT int zmq_close (void *s); +ZMQ_EXPORT int zmq_setsockopt (void *s, int option, const void *optval, + size_t optvallen); +ZMQ_EXPORT int zmq_getsockopt (void *s, int option, void *optval, + size_t *optvallen); +ZMQ_EXPORT int zmq_bind (void *s, const char *addr); +ZMQ_EXPORT int zmq_connect (void *s, const char *addr); +ZMQ_EXPORT int zmq_unbind (void *s, const char *addr); +ZMQ_EXPORT int zmq_disconnect (void *s, const char *addr); +ZMQ_EXPORT int zmq_send (void *s, const void *buf, size_t len, int flags); +ZMQ_EXPORT int zmq_send_const (void *s, const void *buf, size_t len, int flags); +ZMQ_EXPORT int zmq_recv (void *s, void *buf, size_t len, int flags); +ZMQ_EXPORT int zmq_socket_monitor (void *s, const char *addr, int events); + +ZMQ_EXPORT int zmq_sendmsg (void *s, zmq_msg_t *msg, int flags); +ZMQ_EXPORT int zmq_recvmsg (void *s, zmq_msg_t *msg, int flags); + +/* Experimental */ +struct iovec; + +ZMQ_EXPORT int zmq_sendiov (void *s, struct iovec *iov, size_t count, int flags); +ZMQ_EXPORT int zmq_recviov (void *s, struct iovec *iov, size_t *count, int flags); + +/******************************************************************************/ +/* I/O multiplexing. */ +/******************************************************************************/ + +#define ZMQ_POLLIN 1 +#define ZMQ_POLLOUT 2 +#define ZMQ_POLLERR 4 + +typedef struct +{ + void *socket; +#if defined _WIN32 + SOCKET fd; +#else + int fd; +#endif + short events; + short revents; +} zmq_pollitem_t; + +#define ZMQ_POLLITEMS_DFLT 16 + +ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout); + +/* Built-in message proxy (3-way) */ + +ZMQ_EXPORT int zmq_proxy (void *frontend, void *backend, void *capture); + +/* Encode a binary key as printable text using ZMQ RFC 32 */ +ZMQ_EXPORT char *zmq_z85_encode (char *dest, uint8_t *data, size_t size); + +/* Encode a binary key from printable text per ZMQ RFC 32 */ +ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, char *string); + +/* Deprecated aliases */ +#define ZMQ_STREAMER 1 +#define ZMQ_FORWARDER 2 +#define ZMQ_QUEUE 3 +/* Deprecated method */ +ZMQ_EXPORT int zmq_device (int type, void *frontend, void *backend); + +#undef ZMQ_EXPORT + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lib/zeromq/include/zmq_utils.h b/lib/zeromq/include/zmq_utils.h new file mode 100644 index 0000000..9b14aa7 --- /dev/null +++ b/lib/zeromq/include/zmq_utils.h @@ -0,0 +1,105 @@ +/* + Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file + + This file is part of 0MQ. + + 0MQ is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + 0MQ 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 . +*/ + +#ifndef __ZMQ_UTILS_H_INCLUDED__ +#define __ZMQ_UTILS_H_INCLUDED__ + +#include +#include +#include + +/* Define integer types needed for event interface */ +#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS +# include +#elif defined _MSC_VER && _MSC_VER < 1600 +# ifndef int32_t +typedef __int32 int32_t; +# endif +# ifndef uint16_t +typedef unsigned __int16 uint16_t; +# endif +#else +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Handle DSO symbol visibility */ +#if defined _WIN32 +# if defined ZMQ_STATIC +# define ZMQ_EXPORT +# elif defined DLL_EXPORT +# define ZMQ_EXPORT __declspec(dllexport) +# else +# define ZMQ_EXPORT __declspec(dllimport) +# endif +#else +# if defined __SUNPRO_C || defined __SUNPRO_CC +# define ZMQ_EXPORT __global +# elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER +# define ZMQ_EXPORT __attribute__ ((visibility("default"))) +# else +# define ZMQ_EXPORT +# endif +#endif + +/* These functions are documented by man pages */ + +/* Encode data with Z85 encoding. Returns encoded data */ +ZMQ_EXPORT char *zmq_z85_encode (char *dest, uint8_t *data, size_t size); + +/* Decode data with Z85 encoding. Returns decoded data */ +ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, char *string); + +/* 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); + +typedef void (zmq_thread_fn) (void*); + +/* These functions are not documented by man pages */ + +/* Helper functions are used by perf tests so that they don't have to care */ +/* about minutiae of time-related functions on different OS platforms. */ + +/* Starts the stopwatch. Returns the handle to the watch. */ +ZMQ_EXPORT void *zmq_stopwatch_start (void); + +/* Stops the stopwatch. Returns the number of microseconds elapsed since */ +/* the stopwatch was started. */ +ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_); + +/* Sleeps for specified number of seconds. */ +ZMQ_EXPORT void zmq_sleep (int seconds_); + +/* Start a thread. Returns a handle to the thread. */ +ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn* func, void* arg); + +/* Wait for thread to complete then free up resources. */ +ZMQ_EXPORT void zmq_threadclose (void* thread); + +#undef ZMQ_EXPORT + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/nuget/Install.ps1 b/nuget/Install.ps1 index 8626c72..70c8d48 100644 --- a/nuget/Install.ps1 +++ b/nuget/Install.ps1 @@ -1,24 +1,24 @@ -# ------------------------------------------------------------------------- -# Copyright (c) Paulmichael Blasucci. -# -# This source code is subject to terms and conditions of the Apache -# License, Version 2.0. A copy of the license can be found in the -# License.html file at the root of this distribution. -# -# By using this source code in any fashion, you are agreeing to be bound -# by the terms of the Apache License, Version 2.0. -# -# You must not remove this notice, or any other, from this software. -# ------------------------------------------------------------------------- -param($installPath, $toolsPath, $package, $project) - -# get reference to native library -$libzmq = $project.ProjectItems.Item("libzmq.dll") - -# set Build Action to None -$buildAction = $libzmq.Properties.Item("BuildAction") -$buildAction.Value = 0 - -# set Copy to Output Directy to Copy if newer -$copyToOutput = $libzmq.Properties.Item("CopyToOutputDirectory") -$copyToOutput.Value = 2 +# ------------------------------------------------------------------------- +# Copyright (c) Paulmichael Blasucci. +# +# This source code is subject to terms and conditions of the Apache +# License, Version 2.0. A copy of the license can be found in the +# License.html file at the root of this distribution. +# +# By using this source code in any fashion, you are agreeing to be bound +# by the terms of the Apache License, Version 2.0. +# +# You must not remove this notice, or any other, from this software. +# ------------------------------------------------------------------------- +param($installPath, $toolsPath, $package, $project) + +# get reference to native library +$libzmq = $project.ProjectItems.Item("libzmq.dll") + +# set Build Action to None +$buildAction = $libzmq.Properties.Item("BuildAction") +$buildAction.Value = 0 + +# set Copy to Output Directy to Copy if newer +$copyToOutput = $libzmq.Properties.Item("CopyToOutputDirectory") +$copyToOutput.Value = 2 diff --git a/nuget/fszmq.nuspec b/nuget/fszmq.nuspec index a858aa8..3632aaf 100644 --- a/nuget/fszmq.nuspec +++ b/nuget/fszmq.nuspec @@ -1,39 +1,39 @@ - - - - - fszmq - 3.2.4 - fszmq - https://github.com/pblasucci/fs-zmq - https://raw.github.com/pblasucci/fs-zmq/master/nuget/zmq_logo.png - Paulmichael Blasucci - Henrik Feldt,Paulmichael Blasucci - true - https://raw.github.com/pblasucci/fs-zmq/master/LICENSE.txt - © Paulmichael Blasucci. All rights reserved. - An apache-licenced F# binding for the ØMQ concurrent programming library. - An apache-licenced F# binding for the ØMQ concurrent programming library. - fsharp zeromq zmq 0MQ concurrent distributed messaging transport - - - - - - - - - - - + + + + + @project@ + @build.number@ + @authors@ + Henrik Feldt,Paulmichael Blasucci + http://github.com/pblasucci/fszmq/blob/master/LICENSE.txt + http://pblasucci.github.io/fszmq + https://raw.github.com/fsharp/fszmq/master/docs/files/img/zmq_logo.png + true + @summary@ + @description@ + @releaseNotes@ + © Paulmichael Blasucci. All rights reserved. + @tags@ + + + + + + + + + + + diff --git a/nuget/publish.cmd b/nuget/publish.cmd new file mode 100644 index 0000000..9d78130 --- /dev/null +++ b/nuget/publish.cmd @@ -0,0 +1 @@ +@for %%f in (..\bin\Release\*.nupkg) do @..\.nuget\NuGet.exe push %%f \ No newline at end of file diff --git a/src/fszmq/AssemblyInfo.fs b/src/fszmq/AssemblyInfo.fs new file mode 100644 index 0000000..bed630c --- /dev/null +++ b/src/fszmq/AssemblyInfo.fs @@ -0,0 +1,10 @@ +module internal AssemblyInfo +open System.Reflection + +[] +[] +[] +[] +[] + +() diff --git a/fszmq/Constants.fs b/src/fszmq/Constants.fs similarity index 97% rename from fszmq/Constants.fs rename to src/fszmq/Constants.fs index cc2b636..3dad228 100644 --- a/fszmq/Constants.fs +++ b/src/fszmq/Constants.fs @@ -1,201 +1,201 @@ -(*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*) -namespace fszmq - -open System -open System.Globalization -open System.Runtime.InteropServices - -/// -/// A version of two possible states: -/// a triple of integers for the major revision, minor revision and -/// patch number -/// or an `Unknown` indicator -/// -[] -type Version = Version of int * int * int - | Unknown with - - member private V.show = match V with - | Version(m,n,b) -> sprintf "%i.%i.%i" m n b - | Unknown -> "" - - override V.ToString() = V.show - - -/// -/// Represents any error raised by the native ZMQ library. -/// Stores a human-readable summary in the `Message` property. -/// -type ZMQError internal(errnum,errmsg) = - inherit Exception(errmsg) - - /// the ZeroMQ-defined, or OS-defined, error code reported by ZMQ - member __.ErrorNumber = errnum - - -/// Contains commonly-used pre-defined ZMQ values -[] -module ZMQ = - - /// Version of the underlying (native) ZMQ library - [] - let version = - try - let mutable major,minor,patch = 0,0,0 - C.zmq_version(&major,&minor,&patch) - match (major,minor,patch) with - | 0,0,0 -> Unknown - | m,n,b -> Version(m,n,b) - with - | _ -> Unknown - - let internal error() = - let num = C.zmq_errno() - let msg = Marshal.PtrToStringAnsi(C.zmq_strerror(num)) - raise <| ZMQError(num,msg) - - -(* error codes *) - let [] EAGAIN = 11 //TODO: is this cross-platform (WIN + POSIX)? - - let [] private HAUSNUMERO = 156384712 - - let EFSM = HAUSNUMERO + 51 - let ENOCOMPATPROTO = HAUSNUMERO + 52 - let ETERM = HAUSNUMERO + 53 - let EMTHREAD = HAUSNUMERO + 54 - -(* context options *) - let [] IO_THREADS = 1 - let [] MAX_SOCKETS = 2 - // default for new contexts - let [] IO_THREADS_DFLT = 1 - let [] MAX_SOCKETS_DFLT = 1024 - -(* event codes *) - let [] EVENT_CONNECTED = 1 - let [] EVENT_CONNECT_DELAYED = 2 - let [] EVENT_CONNECT_RETRIED = 4 - let [] EVENT_LISTENING = 8 - let [] EVENT_BIND_FAILED = 16 - let [] EVENT_ACCEPTED = 32 - let [] EVENT_ACCEPT_FAILED = 64 - let [] EVENT_CLOSED = 128 - let [] EVENT_CLOSE_FAILED = 256 - let [] EVENT_DISCONNECTED = 512 - -(* socket types *) - let [] PAIR = 0 - let [] PUB = 1 - let [] SUB = 2 - let [] REQ = 3 - let [] REP = 4 - let [] DEALER = 5 - let [] ROUTER = 6 - let [] PULL = 7 - let [] PUSH = 8 - let [] XPUB = 9 - let [] XSUB = 10 - // deprecated socket types - let [] XREQ = DEALER - let [] XREP = ROUTER - -(* socket options *) - - /// (UInt64) I/O thread affinity bit-mask - let [] AFFINITY = 4 - /// (Byte[]) Socket identifier - let [] IDENTITY = 5 - /// (Byte[]) Add subscription filter - let [] SUBSCRIBE = 6 - /// (Byte[]) Remove subscription filter - let [] UNSUBSCRIBE = 7 - /// (Int32) Multicast data rate in kilobits per second - let [] RATE = 8 - /// (Int32) Multicast recovery period in milliseconds - let [] RECOVERY_IVL = 9 - /// (Int32) Send-message buffer size in bytes - let [] SNDBUF = 11 - /// (Int32) Receive-message buffer size in bytes - let [] RCVBUF = 12 - /// (Int32) 1 if more message frames are available, 0 otherwise - let [] RCVMORE = 13 - /// (IntPtr) native file descriptor - let [] FD = 14 - /// (Int32) Socket event state, see all: Polling - let [] EVENTS = 15 - /// (Int32) Socket type - let [] TYPE = 16 - /// (Int32) Pause before shutdown in milliseconds - let [] LINGER = 17 - /// (Int32) Pause before reconnect in milliseconds - let [] RECONNECT_IVL = 18 - /// (Int32) Maximum number of queued peers - let [] BACKLOG = 19 - /// (Int32) Maximum reconnection interval in milliseconds - let [] RECONNECT_IVL_MAX = 21 - /// (Int64) Maximum inbound message size in bytes - let [] MAXMSGSIZE = 22 - /// (Int32) Maximum number of outbound queued messages - let [] SNDHWM = 23 - /// (Int32) Maximum number of inbound queued messages - let [] RCVHWM = 24 - /// (Int32) Time-to-live for each multicast packet in network-hops - let [] MULTICAST_HOPS = 25 - /// (Int32) Timeout period for inbound messages in milliseconds - let [] RCVTIMEO = 27 - /// (Int32) Timeout period for outbound messages in milliseconds - let [] SNDTIMEO = 28 - /// (Int32) 1 restricts native socket to IPv4 only, 0 also allows IPv6 - let [] IPV4ONLY = 31 - /// (String) Last address bound to endpoint - let [] LAST_ENDPOINT = 32 - /// (Int32) 1 causes failure on unroutable message, 0 silently ignores - let [] ROUTER_BEHAVIOR = 33 - /// (Int32) Override OS-level TCP keep-alive - let [] TCP_KEEPALIVE = 34 - /// (Int32) Override OS-level TCP keep-alive - let [] TCP_KEEPALIVE_CNT = 35 - /// (Int32) Override OS-level TCP keep-alive - let [] TCP_KEEPALIVE_IDLE = 36 - /// (Int32) Override OS-level TCP keep-alive - let [] TCP_KEEPALIVE_INTVL = 37 - /// (Byte[]) TCP/IP filters - let [] TCP_ACCEPT_FILTER = 38 - /// (Int32) 1 will deplay pipe attachmet until underlying connection completes - let [] DELAY_ATTACH_ON_CONNECT = 39 - /// (Int32) 1 will resend duplicate messages - let [] XPUB_VERBOSE = 40 - -(* message options *) - - /// (Int32) 1 if more message frames are available, 0 otherwise - let [] MORE = 1 - -(* transmission options *) - - /// Block thread until message frame is sent - let [] WAIT = 0 - /// Queue message frame for sending (return immediately) - let [] DONTWAIT = 1 - /// More message frames will follow the current frame - let [] SNDMORE = 2 - -(* polling *) - let [] POLLIN = 1s - let [] POLLOUT = 2s - let [] POLLERR = 4s - // common timeout lengths for polling - let [] IMMEDIATE = 0L - let [] FOREVER = -1L +(*------------------------------------------------------------------------- +Copyright (c) Paulmichael Blasucci. + +This source code is subject to terms and conditions of the Apache License, +Version 2.0. A copy of the license can be found in the License.html file +at the root of this distribution. + +By using this source code in any fashion, you are agreeing to be bound +by the terms of the Apache License, Version 2.0. + +You must not remove this notice, or any other, from this software. +-------------------------------------------------------------------------*) +namespace fszmq + +open System +open System.Globalization +open System.Runtime.InteropServices + +/// +/// A version of two possible states: +/// a triple of integers for the major revision, minor revision and +/// patch number +/// or an `Unknown` indicator +/// +[] +type Version = Version of int * int * int + | Unknown with + + member private V.show = match V with + | Version(m,n,b) -> sprintf "%i.%i.%i" m n b + | Unknown -> "" + + override V.ToString() = V.show + + +/// +/// Represents any error raised by the native ZMQ library. +/// Stores a human-readable summary in the `Message` property. +/// +type ZMQError internal(errnum,errmsg) = + inherit Exception(errmsg) + + /// the ZeroMQ-defined, or OS-defined, error code reported by ZMQ + member __.ErrorNumber = errnum + + +/// Contains commonly-used pre-defined ZMQ values +[] +module ZMQ = + + /// Version of the underlying (native) ZMQ library + [] + let version = + try + let mutable major,minor,patch = 0,0,0 + C.zmq_version(&major,&minor,&patch) + match (major,minor,patch) with + | 0,0,0 -> Unknown + | m,n,b -> Version(m,n,b) + with + | _ -> Unknown + + let internal error() = + let num = C.zmq_errno() + let msg = Marshal.PtrToStringAnsi(C.zmq_strerror(num)) + raise <| ZMQError(num,msg) + + +(* error codes *) + let [] EAGAIN = 11 //TODO: is this cross-platform (WIN + POSIX)? + + let [] private HAUSNUMERO = 156384712 + + let EFSM = HAUSNUMERO + 51 + let ENOCOMPATPROTO = HAUSNUMERO + 52 + let ETERM = HAUSNUMERO + 53 + let EMTHREAD = HAUSNUMERO + 54 + +(* context options *) + let [] IO_THREADS = 1 + let [] MAX_SOCKETS = 2 + // default for new contexts + let [] IO_THREADS_DFLT = 1 + let [] MAX_SOCKETS_DFLT = 1024 + +(* event codes *) + let [] EVENT_CONNECTED = 1 + let [] EVENT_CONNECT_DELAYED = 2 + let [] EVENT_CONNECT_RETRIED = 4 + let [] EVENT_LISTENING = 8 + let [] EVENT_BIND_FAILED = 16 + let [] EVENT_ACCEPTED = 32 + let [] EVENT_ACCEPT_FAILED = 64 + let [] EVENT_CLOSED = 128 + let [] EVENT_CLOSE_FAILED = 256 + let [] EVENT_DISCONNECTED = 512 + +(* socket types *) + let [] PAIR = 0 + let [] PUB = 1 + let [] SUB = 2 + let [] REQ = 3 + let [] REP = 4 + let [] DEALER = 5 + let [] ROUTER = 6 + let [] PULL = 7 + let [] PUSH = 8 + let [] XPUB = 9 + let [] XSUB = 10 + // deprecated socket types + let [] XREQ = DEALER + let [] XREP = ROUTER + +(* socket options *) + + /// (UInt64) I/O thread affinity bit-mask + let [] AFFINITY = 4 + /// (Byte[]) Socket identifier + let [] IDENTITY = 5 + /// (Byte[]) Add subscription filter + let [] SUBSCRIBE = 6 + /// (Byte[]) Remove subscription filter + let [] UNSUBSCRIBE = 7 + /// (Int32) Multicast data rate in kilobits per second + let [] RATE = 8 + /// (Int32) Multicast recovery period in milliseconds + let [] RECOVERY_IVL = 9 + /// (Int32) Send-message buffer size in bytes + let [] SNDBUF = 11 + /// (Int32) Receive-message buffer size in bytes + let [] RCVBUF = 12 + /// (Int32) 1 if more message frames are available, 0 otherwise + let [] RCVMORE = 13 + /// (IntPtr) native file descriptor + let [] FD = 14 + /// (Int32) Socket event state, see all: Polling + let [] EVENTS = 15 + /// (Int32) Socket type + let [] TYPE = 16 + /// (Int32) Pause before shutdown in milliseconds + let [] LINGER = 17 + /// (Int32) Pause before reconnect in milliseconds + let [] RECONNECT_IVL = 18 + /// (Int32) Maximum number of queued peers + let [] BACKLOG = 19 + /// (Int32) Maximum reconnection interval in milliseconds + let [] RECONNECT_IVL_MAX = 21 + /// (Int64) Maximum inbound message size in bytes + let [] MAXMSGSIZE = 22 + /// (Int32) Maximum number of outbound queued messages + let [] SNDHWM = 23 + /// (Int32) Maximum number of inbound queued messages + let [] RCVHWM = 24 + /// (Int32) Time-to-live for each multicast packet in network-hops + let [] MULTICAST_HOPS = 25 + /// (Int32) Timeout period for inbound messages in milliseconds + let [] RCVTIMEO = 27 + /// (Int32) Timeout period for outbound messages in milliseconds + let [] SNDTIMEO = 28 + /// (Int32) 1 restricts native socket to IPv4 only, 0 also allows IPv6 + let [] IPV4ONLY = 31 + /// (String) Last address bound to endpoint + let [] LAST_ENDPOINT = 32 + /// (Int32) 1 causes failure on unroutable message, 0 silently ignores + let [] ROUTER_BEHAVIOR = 33 + /// (Int32) Override OS-level TCP keep-alive + let [] TCP_KEEPALIVE = 34 + /// (Int32) Override OS-level TCP keep-alive + let [] TCP_KEEPALIVE_CNT = 35 + /// (Int32) Override OS-level TCP keep-alive + let [] TCP_KEEPALIVE_IDLE = 36 + /// (Int32) Override OS-level TCP keep-alive + let [] TCP_KEEPALIVE_INTVL = 37 + /// (Byte[]) TCP/IP filters + let [] TCP_ACCEPT_FILTER = 38 + /// (Int32) 1 will deplay pipe attachmet until underlying connection completes + let [] DELAY_ATTACH_ON_CONNECT = 39 + /// (Int32) 1 will resend duplicate messages + let [] XPUB_VERBOSE = 40 + +(* message options *) + + /// (Int32) 1 if more message frames are available, 0 otherwise + let [] MORE = 1 + +(* transmission options *) + + /// Block thread until message frame is sent + let [] WAIT = 0 + /// Queue message frame for sending (return immediately) + let [] DONTWAIT = 1 + /// More message frames will follow the current frame + let [] SNDMORE = 2 + +(* polling *) + let [] POLLIN = 1s + let [] POLLOUT = 2s + let [] POLLERR = 4s + // common timeout lengths for polling + let [] IMMEDIATE = 0L + let [] FOREVER = -1L diff --git a/fszmq/Context.fs b/src/fszmq/Context.fs similarity index 97% rename from fszmq/Context.fs rename to src/fszmq/Context.fs index 8e42d16..8b894f3 100644 --- a/fszmq/Context.fs +++ b/src/fszmq/Context.fs @@ -1,165 +1,165 @@ -(*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*) -namespace fszmq - -open System -open System.Runtime.CompilerServices -open System.Runtime.InteropServices - -/// Encapsulates data generated by various ZMQ monitoring events -type ZMQEvent = - { Source : nativeint - Event : int - Address : string - Details : int } - with - static member internal Build(source,event,data:C.zmq_event_data_t) = - { Source = source - Event = event - Address = data.address - Details = data.details } - - -/// Contains methods for working with Context instances -[] -module Context = - -(* socket types *) - - /// Creates a Socket, of the given type, within the given context - [] - let newSocket (context:Context) socketType = - new Socket(!!context,socketType) - - /// - /// Creates a peer connected to exactly one other peer. - /// This socket type is used primarily for inter-thread - /// communication across the "inproc" transport. - /// - [] - let pair (context:Context) = ZMQ.PAIR |> newSocket context - - /// - /// Creates a client for sending requests to and receiving replies from - /// a service. - /// This socket type allows only an alternating sequence of - /// `Socket.send(request)` followed by `Socket.recv(reply)` calls. - /// - [] - let req (context:Context) = ZMQ.REQ |> newSocket context - - /// - /// Creates a service to receive requests from and send replies to a - /// client. - /// This socket type allows only an alternating sequence of - /// `Socket.recv(reply)` followed by `Socket.send(request)` calls. - /// - [] - let rep (context:Context) = ZMQ.REP |> newSocket context - - /// - /// Creates an advanced socket type used for extending the request/reply - /// pattern. - /// When a ZMQ.DEALER socket is connected to a ZMQ.REP socket, - /// each message sent must consist of an empty message part, the - /// delimiter, followed by one or more body parts. - /// - [] - let deal (context:Context) = ZMQ.DEALER |> newSocket context - - /// - /// Creates an advanced socket type used for extending the request/reply - /// pattern. - /// When receiving messages a ZMQ.ROUTER socket prepends a - /// message part containing the identity of the originating peer. - /// When sending messages a ZMQ.ROUTER socket removes the first - /// part of the message and uses it to determine the identity of - /// the recipient. - /// - [] - let route (context:Context) = ZMQ.ROUTER |> newSocket context - - /// Creates a pipeline node to receive messages from upstream (PUSH) nodes. - [] - let pull (context:Context) = ZMQ.PULL |> newSocket context - - /// Creates a pipeline node to send messages to downstream (PULL) nodes. - [] - let push (context:Context) = ZMQ.PUSH |> newSocket context - - /// - /// Creates a publisher used to distribute messages to subscribers. - /// NOTE: topical filtering will be done by the subscriber - /// - [] - let pub (context:Context) = ZMQ.PUB |> newSocket context - - /// - /// Creates a subscriber to receive to data distributed by a publisher. - /// Initially a ZMQ.SUB socket is not subscribed to any messages - /// (i.e. one, or more, subscriptions must be manually applied before - /// any messages will be received). - /// - [] - let sub (context:Context) = ZMQ.SUB |> newSocket context - - /// Behaves the same as a publisher, except topical filtering is done - /// by the publisher (before sending a message) - [] - let xpub (context:Context) = ZMQ.XPUB |> newSocket context - - /// - /// Behaves the same as a subscriber, except topical filtering is done - /// by the publisher (before sending a message) - /// NOTE: subscriptions are made by sending a subscription message, - /// in which the first byte is 1 or 0 (subscribe or unsubscribe) - /// and the remainder of the message is the topic - /// - [] - let xsub (context:Context) = ZMQ.XSUB |> newSocket context - -(* context options *) - - /// Gets the value of the given option for the given Context - [] - let get (context:Context) contextOption = - let okay = C.zmq_ctx_get(!!context,contextOption) - if okay = -1 then ZMQ.error() - - /// Sets the given option value for the given Context - [] - let set (context:Context) (contextOption,value) = - let okay = C.zmq_ctx_set(!!context,contextOption,value) - if okay <> 0 then ZMQ.error() - - /// Sets the given block of option values for the given Context - [] - let config (context:Context) (options:seq) = - let set' = set context - options |> Seq.iter (fun input -> set' input) - -(* monitoring *) - - /// - /// Registers a callback function which will receive - /// status events raised by the given Context (and its Sockets) - /// NOTE: this functionality is intended for monitoring only -- - /// excessive time spent in the callback will block the sending and - /// receiving of messages for the Socket passed via the event - /// - [] - let monitor (context:Context) callback = - let bind = (fun s e d -> ZMQEvent.Build(s,e,d) |> callback) - let okay = C.zmq_ctx_set_monitor(!!context,C.zmq_monitor_fn(bind)) - if okay <> 0 then ZMQ.error() +(*------------------------------------------------------------------------- +Copyright (c) Paulmichael Blasucci. + +This source code is subject to terms and conditions of the Apache License, +Version 2.0. A copy of the license can be found in the License.html file +at the root of this distribution. + +By using this source code in any fashion, you are agreeing to be bound +by the terms of the Apache License, Version 2.0. + +You must not remove this notice, or any other, from this software. +-------------------------------------------------------------------------*) +namespace fszmq + +open System +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +/// Encapsulates data generated by various ZMQ monitoring events +type ZMQEvent = + { Source : nativeint + Event : int + Address : string + Details : int } + with + static member internal Build(source,event,data:C.zmq_event_data_t) = + { Source = source + Event = event + Address = data.address + Details = data.details } + + +/// Contains methods for working with Context instances +[] +module Context = + +(* socket types *) + + /// Creates a Socket, of the given type, within the given context + [] + let newSocket (context:Context) socketType = + new Socket(!!context,socketType) + + /// + /// Creates a peer connected to exactly one other peer. + /// This socket type is used primarily for inter-thread + /// communication across the "inproc" transport. + /// + [] + let pair (context:Context) = ZMQ.PAIR |> newSocket context + + /// + /// Creates a client for sending requests to and receiving replies from + /// a service. + /// This socket type allows only an alternating sequence of + /// `Socket.send(request)` followed by `Socket.recv(reply)` calls. + /// + [] + let req (context:Context) = ZMQ.REQ |> newSocket context + + /// + /// Creates a service to receive requests from and send replies to a + /// client. + /// This socket type allows only an alternating sequence of + /// `Socket.recv(reply)` followed by `Socket.send(request)` calls. + /// + [] + let rep (context:Context) = ZMQ.REP |> newSocket context + + /// + /// Creates an advanced socket type used for extending the request/reply + /// pattern. + /// When a ZMQ.DEALER socket is connected to a ZMQ.REP socket, + /// each message sent must consist of an empty message part, the + /// delimiter, followed by one or more body parts. + /// + [] + let deal (context:Context) = ZMQ.DEALER |> newSocket context + + /// + /// Creates an advanced socket type used for extending the request/reply + /// pattern. + /// When receiving messages a ZMQ.ROUTER socket prepends a + /// message part containing the identity of the originating peer. + /// When sending messages a ZMQ.ROUTER socket removes the first + /// part of the message and uses it to determine the identity of + /// the recipient. + /// + [] + let route (context:Context) = ZMQ.ROUTER |> newSocket context + + /// Creates a pipeline node to receive messages from upstream (PUSH) nodes. + [] + let pull (context:Context) = ZMQ.PULL |> newSocket context + + /// Creates a pipeline node to send messages to downstream (PULL) nodes. + [] + let push (context:Context) = ZMQ.PUSH |> newSocket context + + /// + /// Creates a publisher used to distribute messages to subscribers. + /// NOTE: topical filtering will be done by the subscriber + /// + [] + let pub (context:Context) = ZMQ.PUB |> newSocket context + + /// + /// Creates a subscriber to receive to data distributed by a publisher. + /// Initially a ZMQ.SUB socket is not subscribed to any messages + /// (i.e. one, or more, subscriptions must be manually applied before + /// any messages will be received). + /// + [] + let sub (context:Context) = ZMQ.SUB |> newSocket context + + /// Behaves the same as a publisher, except topical filtering is done + /// by the publisher (before sending a message) + [] + let xpub (context:Context) = ZMQ.XPUB |> newSocket context + + /// + /// Behaves the same as a subscriber, except topical filtering is done + /// by the publisher (before sending a message) + /// NOTE: subscriptions are made by sending a subscription message, + /// in which the first byte is 1 or 0 (subscribe or unsubscribe) + /// and the remainder of the message is the topic + /// + [] + let xsub (context:Context) = ZMQ.XSUB |> newSocket context + +(* context options *) + + /// Gets the value of the given option for the given Context + [] + let get (context:Context) contextOption = + let okay = C.zmq_ctx_get(!!context,contextOption) + if okay = -1 then ZMQ.error() + + /// Sets the given option value for the given Context + [] + let set (context:Context) (contextOption,value) = + let okay = C.zmq_ctx_set(!!context,contextOption,value) + if okay <> 0 then ZMQ.error() + + /// Sets the given block of option values for the given Context + [] + let config (context:Context) (options:seq) = + let set' = set context + options |> Seq.iter (fun input -> set' input) + +(* monitoring *) + + /// + /// Registers a callback function which will receive + /// status events raised by the given Context (and its Sockets) + /// NOTE: this functionality is intended for monitoring only -- + /// excessive time spent in the callback will block the sending and + /// receiving of messages for the Socket passed via the event + /// + [] + let monitor (context:Context) callback = + let bind = (fun s e d -> ZMQEvent.Build(s,e,d) |> callback) + let okay = C.zmq_ctx_set_monitor(!!context,C.zmq_monitor_fn(bind)) + if okay <> 0 then ZMQ.error() diff --git a/fszmq/Core.fs b/src/fszmq/Core.fs similarity index 96% rename from fszmq/Core.fs rename to src/fszmq/Core.fs index af8ec87..2423671 100644 --- a/fszmq/Core.fs +++ b/src/fszmq/Core.fs @@ -1,117 +1,117 @@ -(*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*) -namespace fszmq - -open System -open System.Runtime.InteropServices - -/// -/// Provides a memory-managed wrapper over ZMQ message operations -/// -type Frame(?source:byte array) = - let mutable disposed = false - let mutable _memory = Marshal.AllocHGlobal(C.ZMQ_MSG_T_SIZE) - - let (|Source|_|) = function - | None - | Some null -> None - | Some data -> Some(data |> Array.length |> unativeint,data) - - do (* ctor *) - let okay,size,data = - match source with - | Source(size,data) -> C.zmq_msg_init_size(_memory,size),size,data - | _ -> C.zmq_msg_init (_memory ), 0un,[||] - if okay <> 0 then ZMQ.error() - Marshal.Copy(data,0,C.zmq_msg_data(_memory),int size) - - member __.Handle = _memory - - member __.Data = let size = C.zmq_msg_size(_memory) |> int - let data = C.zmq_msg_data(_memory) - let output = Array.zeroCreate size - Marshal.Copy(data,output,0,size) - output - member __.Size = C.zmq_msg_size(_memory) |> int - - override __.Finalize() = - if not disposed then - disposed <- true - let okay = C.zmq_msg_close(_memory) - Marshal.FreeHGlobal(_memory) - _memory <- 0n - if okay <> 0 then ZMQ.error() - - interface IDisposable with - - member self.Dispose() = - self.Finalize() - GC.SuppressFinalize(self) - - -/// An abstraction of an asynchronous message queue, -/// with the exact queuing and message-exchange -/// semantics determined by the socket type -type Socket internal(context,socketType) = - - let mutable disposed = false - let mutable _socket = C.zmq_socket(context,socketType) - - do if _socket = 0n then ZMQ.error() - - /// - /// Pointer to underlying (native) ZMQ socket - /// NOTE: For internal use only. - /// - member __.Handle = _socket - - override __.Finalize() = - if not disposed then - disposed <- true - let okay = C.zmq_close(_socket) - _socket <- 0n - if okay <> 0 then ZMQ.error() - - interface IDisposable with - - member self.Dispose() = - self.Finalize() - GC.SuppressFinalize(self) - - -/// Represents the container for a group of sockets in a node -type Context() = - - let mutable disposed = false - let mutable _context = C.zmq_ctx_new() - - do if _context = 0n then ZMQ.error() - - /// - /// Pointer to underlying (native) ZMQ context - /// NOTE: For internal use only. - /// - member __.Handle = _context - - override __.Finalize() = - if not disposed then - disposed <- true - let okay = C.zmq_ctx_destroy(_context) - _context <- 0n - if okay <> 0 then ZMQ.error() - - interface IDisposable with - - member self.Dispose() = - self.Finalize() - GC.SuppressFinalize(self) +(*------------------------------------------------------------------------- +Copyright (c) Paulmichael Blasucci. + +This source code is subject to terms and conditions of the Apache License, +Version 2.0. A copy of the license can be found in the License.html file +at the root of this distribution. + +By using this source code in any fashion, you are agreeing to be bound +by the terms of the Apache License, Version 2.0. + +You must not remove this notice, or any other, from this software. +-------------------------------------------------------------------------*) +namespace fszmq + +open System +open System.Runtime.InteropServices + +/// +/// Provides a memory-managed wrapper over ZMQ message operations +/// +type Frame(?source:byte array) = + let mutable disposed = false + let mutable _memory = Marshal.AllocHGlobal(C.ZMQ_MSG_T_SIZE) + + let (|Source|_|) = function + | None + | Some null -> None + | Some data -> Some(data |> Array.length |> unativeint,data) + + do (* ctor *) + let okay,size,data = + match source with + | Source(size,data) -> C.zmq_msg_init_size(_memory,size),size,data + | _ -> C.zmq_msg_init (_memory ), 0un,[||] + if okay <> 0 then ZMQ.error() + Marshal.Copy(data,0,C.zmq_msg_data(_memory),int size) + + member __.Handle = _memory + + member __.Data = let size = C.zmq_msg_size(_memory) |> int + let data = C.zmq_msg_data(_memory) + let output = Array.zeroCreate size + Marshal.Copy(data,output,0,size) + output + member __.Size = C.zmq_msg_size(_memory) |> int + + override __.Finalize() = + if not disposed then + disposed <- true + let okay = C.zmq_msg_close(_memory) + Marshal.FreeHGlobal(_memory) + _memory <- 0n + if okay <> 0 then ZMQ.error() + + interface IDisposable with + + member self.Dispose() = + self.Finalize() + GC.SuppressFinalize(self) + + +/// An abstraction of an asynchronous message queue, +/// with the exact queuing and message-exchange +/// semantics determined by the socket type +type Socket internal(context,socketType) = + + let mutable disposed = false + let mutable _socket = C.zmq_socket(context,socketType) + + do if _socket = 0n then ZMQ.error() + + /// + /// Pointer to underlying (native) ZMQ socket + /// NOTE: For internal use only. + /// + member __.Handle = _socket + + override __.Finalize() = + if not disposed then + disposed <- true + let okay = C.zmq_close(_socket) + _socket <- 0n + if okay <> 0 then ZMQ.error() + + interface IDisposable with + + member self.Dispose() = + self.Finalize() + GC.SuppressFinalize(self) + + +/// Represents the container for a group of sockets in a node +type Context() = + + let mutable disposed = false + let mutable _context = C.zmq_ctx_new() + + do if _context = 0n then ZMQ.error() + + /// + /// Pointer to underlying (native) ZMQ context + /// NOTE: For internal use only. + /// + member __.Handle = _context + + override __.Finalize() = + if not disposed then + disposed <- true + let okay = C.zmq_ctx_destroy(_context) + _context <- 0n + if okay <> 0 then ZMQ.error() + + interface IDisposable with + + member self.Dispose() = + self.Finalize() + GC.SuppressFinalize(self) diff --git a/fszmq/Marshal.fs b/src/fszmq/Marshal.fs similarity index 97% rename from fszmq/Marshal.fs rename to src/fszmq/Marshal.fs index aacc099..566a077 100644 --- a/fszmq/Marshal.fs +++ b/src/fszmq/Marshal.fs @@ -1,59 +1,59 @@ -(*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*) -namespace fszmq - -open System -open System.Runtime.InteropServices - -[] -module internal Marshal = - - //NOTE: this operator isn't really related to Marshaling, - // but this is a convenient location for it's definition - let inline (!!) (w : ^w) = (^w : (member Handle : nativeint) w) - -(* reading native values *) - let inline readInt32 pointer = Marshal.ReadInt32(pointer) - let inline readInt64 pointer = Marshal.ReadInt64(pointer) - - let inline readBool pointer = - (Marshal.ReadInt32 >> Convert.ToBoolean) pointer - - let inline readUInt64 pointer = - (Marshal.ReadInt64 >> Convert.ToUInt64) pointer - - let inline readBytes (length,pointer) = - let length = int length - let value = Array.zeroCreate length - Marshal.Copy(pointer,value,0,length) - value - - let inline readString (length,pointer) = - System.Text.Encoding.UTF8.GetString(readBytes (length,pointer)) - -(* writing native values *) - let inline writeInt32 value pointer = Marshal.WriteInt32(pointer,value) - let inline writeInt64 value pointer = Marshal.WriteInt64(pointer,value) - - let inline writeBool value pointer = - Marshal.WriteInt32(pointer,if value then 1 else 0) - - let inline writeUInt64 (value:UInt64) pointer = - Marshal.WriteInt64(pointer,int64 value) - - let inline writeString value pointer = - let bytes = System.Text.Encoding.UTF8.GetBytes(string value) - Marshal.Copy(bytes,0,pointer,bytes.Length) - - let inline writeBytes (value:byte[]) pointer = - Marshal.Copy(value,0,pointer,value.Length) +(*------------------------------------------------------------------------- +Copyright (c) Paulmichael Blasucci. + +This source code is subject to terms and conditions of the Apache License, +Version 2.0. A copy of the license can be found in the License.html file +at the root of this distribution. + +By using this source code in any fashion, you are agreeing to be bound +by the terms of the Apache License, Version 2.0. + +You must not remove this notice, or any other, from this software. +-------------------------------------------------------------------------*) +namespace fszmq + +open System +open System.Runtime.InteropServices + +[] +module internal Marshal = + + //NOTE: this operator isn't really related to Marshaling, + // but this is a convenient location for it's definition + let inline (!!) (w : ^w) = (^w : (member Handle : nativeint) w) + +(* reading native values *) + let inline readInt32 pointer = Marshal.ReadInt32(pointer) + let inline readInt64 pointer = Marshal.ReadInt64(pointer) + + let inline readBool pointer = + (Marshal.ReadInt32 >> Convert.ToBoolean) pointer + + let inline readUInt64 pointer = + (Marshal.ReadInt64 >> Convert.ToUInt64) pointer + + let inline readBytes (length,pointer) = + let length = int length + let value = Array.zeroCreate length + Marshal.Copy(pointer,value,0,length) + value + + let inline readString (length,pointer) = + System.Text.Encoding.UTF8.GetString(readBytes (length,pointer)) + +(* writing native values *) + let inline writeInt32 value pointer = Marshal.WriteInt32(pointer,value) + let inline writeInt64 value pointer = Marshal.WriteInt64(pointer,value) + + let inline writeBool value pointer = + Marshal.WriteInt32(pointer,if value then 1 else 0) + + let inline writeUInt64 (value:UInt64) pointer = + Marshal.WriteInt64(pointer,int64 value) + + let inline writeString value pointer = + let bytes = System.Text.Encoding.UTF8.GetBytes(string value) + Marshal.Copy(bytes,0,pointer,bytes.Length) + + let inline writeBytes (value:byte[]) pointer = + Marshal.Copy(value,0,pointer,value.Length) diff --git a/fszmq/Native.fs b/src/fszmq/Native.fs similarity index 97% rename from fszmq/Native.fs rename to src/fszmq/Native.fs index 704cc70..a16c4bc 100644 --- a/fszmq/Native.fs +++ b/src/fszmq/Native.fs @@ -1,196 +1,196 @@ -(*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*) -namespace fszmq - -open System -open System.Runtime.InteropServices - -#nowarn "9" // possible unverifiable IL generation -//NOTE: spurious warning, see `zmq_event_data_t`,`zmq_pollitem_t` for info - -[] -module internal C = - - type HANDLE = nativeint - type zmq_msg_t = nativeint - type size_t = unativeint - -(* version *) - [] - extern void zmq_version(int& major, int& minor, int& patch) - -(* error handling *) - [] - extern int zmq_errno() - - [] - extern HANDLE zmq_strerror(int errno) - -(* message *) - let [] ZMQ_MSG_T_SIZE = 32 - - [] - extern int zmq_msg_init(zmq_msg_t msg) - - [] - extern int zmq_msg_init_size(zmq_msg_t msg, size_t size) - - [] - extern int zmq_msg_send(zmq_msg_t msg, HANDLE socket, int flags) - - [] - extern int zmq_msg_recv(zmq_msg_t msg, HANDLE socket, int flags) - - [] - extern int zmq_msg_close(zmq_msg_t msg) - - [] - extern void *zmq_msg_data(zmq_msg_t msg) - - [] - extern size_t zmq_msg_size(zmq_msg_t msg) - - [] - extern int zmq_msg_more(zmq_msg_t msg) - - [] - extern int zmq_msg_get(zmq_msg_t msg, int option) - - [] - extern int zmq_msg_set(zmq_msg_t msg, int option, int optval) - - (* :: NOTE :: - The functions `zmq_msg_init_data`, `zmq_msg_move`, and `zmq_msg_copy` - have NOT been implemented because they make no real sense in a - memory-managed environment. If you find yourself needing the - nano-second speed-ups those methods offer, you should be working - directly in the native library -- and NOT in a higher-level binding *) - -(* socket *) - [] - extern HANDLE zmq_socket(HANDLE context, int socketType) - - [] - extern int zmq_close(HANDLE socket) - - [] - extern int zmq_setsockopt(HANDLE socket - ,int option - ,HANDLE value - ,size_t size) - - [] - extern int zmq_getsockopt(HANDLE socket - ,int option - ,HANDLE value - ,size_t& size) - - [] - extern int zmq_bind(HANDLE socket, - [] - string address) - - [] - extern int zmq_connect(HANDLE socket, - [] - string address) - - [] - extern int zmq_unbind(HANDLE socket, - [] - string address) - - [] - extern int zmq_disconnect(HANDLE socket, - [] - string address) - -(* context *) - [] - type zmq_event_data_t = - struct - val mutable address : string - val mutable details : int - - (* :: NOTE :: - With the current F# compiler, any use of the StructLayout attribute - produces the warning: "Uses of this construct may result in the - generation of unverifiable .NET IL code". However, zmq_event_data_t - does _not_ have "explicit packing and an object reference which - overlaps a built-in value type or a part of another object - reference". So, at least by the ECMA-355 specification, it should - still produce verifiable code. A quick pass of fszmq.dll through - peverify.exe confirms this saftey assertion. Microsoft has - acknowledged this bug, but considers it a low priority. Thus, a - #nowarn pragma has been included near the top of the this file. *) - end - - type zmq_monitor_fn = delegate of HANDLE * int * zmq_event_data_t -> unit - - [] - extern HANDLE zmq_ctx_new() - - [] - extern int zmq_ctx_destroy(HANDLE context) - - [] - extern int zmq_ctx_set(HANDLE context, int option, int value) - - [] - extern int zmq_ctx_get(HANDLE context, int option) - - [] - extern int zmq_ctx_set_monitor (HANDLE context, zmq_monitor_fn monitor) - -(* polling *) - [] - type zmq_pollitem_t = - struct - val mutable socket : HANDLE - val mutable fd : HANDLE - val mutable events : int16 - val mutable revents : int16 - - new(socket,events) = { socket = socket - fd = 0n - events = events - revents = 0s } - - (* :: NOTE :: - With the current F# compiler, any use of the StructLayout attribute - produces the warning: "Uses of this construct may result in the - generation of unverifiable .NET IL code". However, zmq_pollitem_t - does _not_ have "explicit packing and an object reference which - overlaps a built-in value type or a part of another object - reference". So, at least by the ECMA-355 specification, it should - still produce verifiable code. A quick pass of fszmq.dll through - peverify.exe confirms this saftey assertion. Microsoft has - acknowledged this bug, but considers it a low priority. Thus, a - #nowarn pragma has been included near the top of the this file. *) - end - - [] - extern int zmq_poll ([]zmq_pollitem_t[] items, - int count, - int64 timeout) - -(* proxy *) - [] - extern int zmq_proxy (HANDLE frontend, HANDLE backend, HANDLE capture) - - (* :: NOTE :: - The zmq_proxy function replaces all previous "in the box" 0MQ devices. - Said devices API has been deprecated and should no longer be used. - Additionally, the (optional) capture socket on zmq_proxy is an good - logging and auditing tool. *) +(*------------------------------------------------------------------------- +Copyright (c) Paulmichael Blasucci. + +This source code is subject to terms and conditions of the Apache License, +Version 2.0. A copy of the license can be found in the License.html file +at the root of this distribution. + +By using this source code in any fashion, you are agreeing to be bound +by the terms of the Apache License, Version 2.0. + +You must not remove this notice, or any other, from this software. +-------------------------------------------------------------------------*) +namespace fszmq + +open System +open System.Runtime.InteropServices + +#nowarn "9" // possible unverifiable IL generation +//NOTE: spurious warning, see `zmq_event_data_t`,`zmq_pollitem_t` for info + +[] +module internal C = + + type HANDLE = nativeint + type zmq_msg_t = nativeint + type size_t = unativeint + +(* version *) + [] + extern void zmq_version(int& major, int& minor, int& patch) + +(* error handling *) + [] + extern int zmq_errno() + + [] + extern HANDLE zmq_strerror(int errno) + +(* message *) + let [] ZMQ_MSG_T_SIZE = 32 + + [] + extern int zmq_msg_init(zmq_msg_t msg) + + [] + extern int zmq_msg_init_size(zmq_msg_t msg, size_t size) + + [] + extern int zmq_msg_send(zmq_msg_t msg, HANDLE socket, int flags) + + [] + extern int zmq_msg_recv(zmq_msg_t msg, HANDLE socket, int flags) + + [] + extern int zmq_msg_close(zmq_msg_t msg) + + [] + extern void *zmq_msg_data(zmq_msg_t msg) + + [] + extern size_t zmq_msg_size(zmq_msg_t msg) + + [] + extern int zmq_msg_more(zmq_msg_t msg) + + [] + extern int zmq_msg_get(zmq_msg_t msg, int option) + + [] + extern int zmq_msg_set(zmq_msg_t msg, int option, int optval) + + (* :: NOTE :: + The functions `zmq_msg_init_data`, `zmq_msg_move`, and `zmq_msg_copy` + have NOT been implemented because they make no real sense in a + memory-managed environment. If you find yourself needing the + nano-second speed-ups those methods offer, you should be working + directly in the native library -- and NOT in a higher-level binding *) + +(* socket *) + [] + extern HANDLE zmq_socket(HANDLE context, int socketType) + + [] + extern int zmq_close(HANDLE socket) + + [] + extern int zmq_setsockopt(HANDLE socket + ,int option + ,HANDLE value + ,size_t size) + + [] + extern int zmq_getsockopt(HANDLE socket + ,int option + ,HANDLE value + ,size_t& size) + + [] + extern int zmq_bind(HANDLE socket, + [] + string address) + + [] + extern int zmq_connect(HANDLE socket, + [] + string address) + + [] + extern int zmq_unbind(HANDLE socket, + [] + string address) + + [] + extern int zmq_disconnect(HANDLE socket, + [] + string address) + +(* context *) + [] + type zmq_event_data_t = + struct + val mutable address : string + val mutable details : int + + (* :: NOTE :: + With the current F# compiler, any use of the StructLayout attribute + produces the warning: "Uses of this construct may result in the + generation of unverifiable .NET IL code". However, zmq_event_data_t + does _not_ have "explicit packing and an object reference which + overlaps a built-in value type or a part of another object + reference". So, at least by the ECMA-355 specification, it should + still produce verifiable code. A quick pass of fszmq.dll through + peverify.exe confirms this saftey assertion. Microsoft has + acknowledged this bug, but considers it a low priority. Thus, a + #nowarn pragma has been included near the top of the this file. *) + end + + type zmq_monitor_fn = delegate of HANDLE * int * zmq_event_data_t -> unit + + [] + extern HANDLE zmq_ctx_new() + + [] + extern int zmq_ctx_destroy(HANDLE context) + + [] + extern int zmq_ctx_set(HANDLE context, int option, int value) + + [] + extern int zmq_ctx_get(HANDLE context, int option) + + [] + extern int zmq_ctx_set_monitor (HANDLE context, zmq_monitor_fn monitor) + +(* polling *) + [] + type zmq_pollitem_t = + struct + val mutable socket : HANDLE + val mutable fd : HANDLE + val mutable events : int16 + val mutable revents : int16 + + new(socket,events) = { socket = socket + fd = 0n + events = events + revents = 0s } + + (* :: NOTE :: + With the current F# compiler, any use of the StructLayout attribute + produces the warning: "Uses of this construct may result in the + generation of unverifiable .NET IL code". However, zmq_pollitem_t + does _not_ have "explicit packing and an object reference which + overlaps a built-in value type or a part of another object + reference". So, at least by the ECMA-355 specification, it should + still produce verifiable code. A quick pass of fszmq.dll through + peverify.exe confirms this saftey assertion. Microsoft has + acknowledged this bug, but considers it a low priority. Thus, a + #nowarn pragma has been included near the top of the this file. *) + end + + [] + extern int zmq_poll ([]zmq_pollitem_t[] items, + int count, + int64 timeout) + +(* proxy *) + [] + extern int zmq_proxy (HANDLE frontend, HANDLE backend, HANDLE capture) + + (* :: NOTE :: + The zmq_proxy function replaces all previous "in the box" 0MQ devices. + Said devices API has been deprecated and should no longer be used. + Additionally, the (optional) capture socket on zmq_proxy is an good + logging and auditing tool. *) diff --git a/fszmq/Polling.fs b/src/fszmq/Polling.fs similarity index 97% rename from fszmq/Polling.fs rename to src/fszmq/Polling.fs index f7803b2..2c86118 100644 --- a/fszmq/Polling.fs +++ b/src/fszmq/Polling.fs @@ -1,107 +1,107 @@ -(*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*) -namespace fszmq - -open System -open System.Collections.Generic -open System.Runtime.CompilerServices - -/// -/// For use with the Poll module... -/// Associates a callback with a Socket instance and one or more -/// events, such that the callback is invoked when the event(s) occurs on -/// the Socket instance -/// NOTE: all sockets passed to Polling.poll MUST share the -/// same context and belong to the thread calling Polling.poll -/// -type Poll = Poll of events * Socket * (Socket -> unit) with - - /// Creates a poll item in a way friendly to languages other then F# - static member Create(events,socket,callback:Action) = - Poll(events,socket,fun s -> callback.Invoke(s)) - -and events = int16 - -/// Contains methods for working with ZMQ's polling capabilities -[] -module Polling = - - /// Creates a Poll item for the socket which will - /// invoke the callback when the socket receives a message - [] - let pollIn fn socket = Poll(ZMQ.POLLIN,socket,fn) - - /// Creates a Poll item for the socket which will - /// invoke the callback when the socket sends a message - [] - let pollOut fn socket = Poll(ZMQ.POLLOUT,socket,fn) - - /// Creates a Poll item for the socket which will - /// invoke the callback when the socket sends or receives messages - [] - let pollIO fn socket = Poll(ZMQ.POLLIN ||| ZMQ.POLLOUT,socket,fn) - - let private poller (Poll(v,s,_)) = C.zmq_pollitem_t(!!s,v) - let private invoke (Poll(_,s,f)) = f s - - /// - /// Performs a single polling run across the give sequence of - /// Poll items, waiting up to the given timeout. - /// Returns true when one or more callbacks have been invoked, - /// returns false otherwise - /// NOTE: All items passed to Polling.poll MUST share the same - /// context and belong to the thread calling Polling.poll - /// - [] - let poll timeout items = - let items = items |> Array.ofSeq - let items' = items |> Array.map poller - match C.zmq_poll(items',items'.Length,timeout) with - | 0 -> false (* pass *) - | n when n > 0 -> for i in 0 .. items'.GetUpperBound(0) do - let e,r = items'.[i].events,items'.[i].revents - if e &&& r = e then items.[i] |> invoke - true - | _ -> ZMQ.error() - - /// Calls Polling.poll with the given sequence of - /// Poll items and 0 microseconds timeout - [] - let pollNow items = poll ZMQ.IMMEDIATE items - - /// Calls Polling.poll with the given sequence of Poll items and no timeout, - /// effectively causing the polling loop to block indefinitely. - [] - let pollForever items = poll ZMQ.FOREVER items - -/// Utilities for working with Polling from languages other than F# -[] -type PollingExtensions = - - /// Creates a Poll item for the socket which will - /// invoke the callback when the socket receives a message - [] - static member AsPollIn (socket,callback:Action<_>) = - socket |> Polling.pollIn (fun s -> callback.Invoke(s)) - - /// Creates a Poll item for the socket which will - /// invoke the callback when the socket receives a message - [] - static member AsPollOut (socket,callback:Action<_>) = - socket |> Polling.pollOut (fun s -> callback.Invoke(s)) - - /// Creates a Poll item for the socket which will - /// invoke the callback when the socket sends or receives a message - [] - static member AsPollIO (socket,callback:Action<_>) = - socket |> Polling.pollIO (fun s -> callback.Invoke(s)) +(*------------------------------------------------------------------------- +Copyright (c) Paulmichael Blasucci. + +This source code is subject to terms and conditions of the Apache License, +Version 2.0. A copy of the license can be found in the License.html file +at the root of this distribution. + +By using this source code in any fashion, you are agreeing to be bound +by the terms of the Apache License, Version 2.0. + +You must not remove this notice, or any other, from this software. +-------------------------------------------------------------------------*) +namespace fszmq + +open System +open System.Collections.Generic +open System.Runtime.CompilerServices + +/// +/// For use with the Poll module... +/// Associates a callback with a Socket instance and one or more +/// events, such that the callback is invoked when the event(s) occurs on +/// the Socket instance +/// NOTE: all sockets passed to Polling.poll MUST share the +/// same context and belong to the thread calling Polling.poll +/// +type Poll = Poll of events * Socket * (Socket -> unit) with + + /// Creates a poll item in a way friendly to languages other then F# + static member Create(events,socket,callback:Action) = + Poll(events,socket,fun s -> callback.Invoke(s)) + +and events = int16 + +/// Contains methods for working with ZMQ's polling capabilities +[] +module Polling = + + /// Creates a Poll item for the socket which will + /// invoke the callback when the socket receives a message + [] + let pollIn fn socket = Poll(ZMQ.POLLIN,socket,fn) + + /// Creates a Poll item for the socket which will + /// invoke the callback when the socket sends a message + [] + let pollOut fn socket = Poll(ZMQ.POLLOUT,socket,fn) + + /// Creates a Poll item for the socket which will + /// invoke the callback when the socket sends or receives messages + [] + let pollIO fn socket = Poll(ZMQ.POLLIN ||| ZMQ.POLLOUT,socket,fn) + + let private poller (Poll(v,s,_)) = C.zmq_pollitem_t(!!s,v) + let private invoke (Poll(_,s,f)) = f s + + /// + /// Performs a single polling run across the give sequence of + /// Poll items, waiting up to the given timeout. + /// Returns true when one or more callbacks have been invoked, + /// returns false otherwise + /// NOTE: All items passed to Polling.poll MUST share the same + /// context and belong to the thread calling Polling.poll + /// + [] + let poll timeout items = + let items = items |> Array.ofSeq + let items' = items |> Array.map poller + match C.zmq_poll(items',items'.Length,timeout) with + | 0 -> false (* pass *) + | n when n > 0 -> for i in 0 .. items'.GetUpperBound(0) do + let e,r = items'.[i].events,items'.[i].revents + if e &&& r = e then items.[i] |> invoke + true + | _ -> ZMQ.error() + + /// Calls Polling.poll with the given sequence of + /// Poll items and 0 microseconds timeout + [] + let pollNow items = poll ZMQ.IMMEDIATE items + + /// Calls Polling.poll with the given sequence of Poll items and no timeout, + /// effectively causing the polling loop to block indefinitely. + [] + let pollForever items = poll ZMQ.FOREVER items + +/// Utilities for working with Polling from languages other than F# +[] +type PollingExtensions = + + /// Creates a Poll item for the socket which will + /// invoke the callback when the socket receives a message + [] + static member AsPollIn (socket,callback:Action<_>) = + socket |> Polling.pollIn (fun s -> callback.Invoke(s)) + + /// Creates a Poll item for the socket which will + /// invoke the callback when the socket receives a message + [] + static member AsPollOut (socket,callback:Action<_>) = + socket |> Polling.pollOut (fun s -> callback.Invoke(s)) + + /// Creates a Poll item for the socket which will + /// invoke the callback when the socket sends or receives a message + [] + static member AsPollIO (socket,callback:Action<_>) = + socket |> Polling.pollIO (fun s -> callback.Invoke(s)) diff --git a/fszmq/Proxy.fs b/src/fszmq/Proxy.fs similarity index 100% rename from fszmq/Proxy.fs rename to src/fszmq/Proxy.fs diff --git a/fszmq/Scratch.fsx b/src/fszmq/Scratch.fsx similarity index 90% rename from fszmq/Scratch.fsx rename to src/fszmq/Scratch.fsx index e8306c0..4ffe0f1 100644 --- a/fszmq/Scratch.fsx +++ b/src/fszmq/Scratch.fsx @@ -1,43 +1,43 @@ -(*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*) -open System - -Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ + @"..\..\zeromq" - -#load "Native.fs" -open fszmq -#load "Constants.fs" -open fszmq -#load "Core.fs" -open fszmq -#load "Marshal.fs" -open fszmq -#load "Socket.fs" -open fszmq -open fszmq.Socket -#load "Context.fs" -open fszmq -open fszmq.Context -#load "Polling.fs" -open fszmq -open fszmq.Polling -#load "Proxy.fs" -open fszmq -open fszmq.Proxying - -#time "on" - -let encode = string >> System.Text.Encoding.ASCII.GetBytes -let decode = System.Text.Encoding.ASCII.GetString - -printfn "%A" ZMQ.version +(*------------------------------------------------------------------------- +Copyright (c) Paulmichael Blasucci. + +This source code is subject to terms and conditions of the Apache License, +Version 2.0. A copy of the license can be found in the License.html file +at the root of this distribution. + +By using this source code in any fashion, you are agreeing to be bound +by the terms of the Apache License, Version 2.0. + +You must not remove this notice, or any other, from this software. +-------------------------------------------------------------------------*) +open System + +Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ + @"..\..\..\lib\zeromq\x86" + +#load "Native.fs" +open fszmq +#load "Constants.fs" +open fszmq +#load "Core.fs" +open fszmq +#load "Marshal.fs" +open fszmq +#load "Socket.fs" +open fszmq +open fszmq.Socket +#load "Context.fs" +open fszmq +open fszmq.Context +#load "Polling.fs" +open fszmq +open fszmq.Polling +#load "Proxy.fs" +open fszmq +open fszmq.Proxying + +#time "on" + +let encode = string >> System.Text.Encoding.ASCII.GetBytes +let decode = System.Text.Encoding.ASCII.GetString + +printfn "%A" ZMQ.version diff --git a/fszmq/Socket.fs b/src/fszmq/Socket.fs similarity index 97% rename from fszmq/Socket.fs rename to src/fszmq/Socket.fs index 3a9b875..59d2386 100644 --- a/fszmq/Socket.fs +++ b/src/fszmq/Socket.fs @@ -1,218 +1,218 @@ -(*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*) -namespace fszmq - -open System -open System.Runtime.CompilerServices -open System.Runtime.InteropServices - -/// Contains methods for working with Socket instances -[] -module Socket = - -(* connectivity *) - - /// Causes an endpoint to start accepting - /// connections at the given address - [] - let bind (socket:Socket) address = - let okay = C.zmq_bind(!!socket,address) - if okay <> 0 then ZMQ.error() - - /// Causes an endpoint to stop accepting - /// connections at the given address - [] - let unbind (socket:Socket) address = - let okay = C.zmq_unbind(!!socket,address) - if okay <> 0 then ZMQ.error() - - /// Connects to an endpoint to the given address - [] - let connect (socket:Socket) address = - let okay = C.zmq_connect(!!socket,address) - if okay <> 0 then ZMQ.error() - - /// Disconnects to an endpoint from the given address - [] - let disconnect (socket:Socket) address = - let okay = C.zmq_disconnect(!!socket,address) - if okay <> 0 then ZMQ.error() - -(* socket options *) - - /// Gets the value of the given option for the given Socket - [] - let get<'t> (socket:Socket) socketOption : 't = - let size,read = - let t = typeof<'t> - if t = typeof then 4,(snd >> readInt32 >> box) - elif t = typeof then 4,(snd >> readBool >> box) - elif t = typeof then 8,(snd >> readInt64 >> box) - elif t = typeof then 8,(snd >> readUInt64 >> box) - elif t = typeof then 255,( readString >> box) - elif t = typeof then 255,( readBytes >> box) - else invalidOp "Invalid data type" - let buffer = Marshal.AllocHGlobal(size) - try - let mutable size' = unativeint size - let okay = C.zmq_getsockopt(!!socket,socketOption,buffer,&size') - if okay <> 0 then ZMQ.error() - downcast read (size',buffer) - finally - Marshal.FreeHGlobal(buffer) - - /// Sets the given option value for the given Socket - [] - let set (socket:Socket) (socketOption,value:'t) = - let size,write = - match box value with - | :? (int32 ) as v -> sizeof,(writeInt32 v) - | :? (bool ) as v -> sizeof,(writeBool v) - | :? (int64 ) as v -> sizeof,(writeInt64 v) - | :? (uint64) as v -> sizeof,(writeUInt64 v) - | :? (string) as v -> v.Length ,(writeString v) - | :? (byte[]) as v -> v.Length ,(writeBytes v) - | _ -> invalidOp "Invalid data type" - let buffer = Marshal.AllocHGlobal(size) - try - write(buffer) - let okay = C.zmq_setsockopt(!!socket - ,socketOption - ,buffer - ,unativeint size) - if okay <> 0 then ZMQ.error() - finally - Marshal.FreeHGlobal(buffer) - - /// Sets the given block of option values for the given Socket - [] - let config socket (socketOptions: (int * obj) seq) = - let set' = set socket in socketOptions |> Seq.iter (set') - -(* subscripitions *) - - /// Adds one subscription for each of the given topics - [] - let subscribe socket topics = - let setter (t:byte[]) = set socket (ZMQ.SUBSCRIBE,t) |> ignore - topics |> Seq.iter setter - - /// Removes one subscription for each of the given topics - [] - let unsubscribe socket topics = - let setter (t:byte[]) = set socket (ZMQ.UNSUBSCRIBE,t) |> ignore - topics |> Seq.iter setter - -(* message sending *) - let private (|Okay|Busy|Fail|) = function - | -1 -> match C.zmq_errno() with - | ZMQ.EAGAIN -> Busy - | _ -> Fail - | _ -> Okay - - /// Sends a frame, with the given flags, returning true (or false) - /// if the send was successful (or should be re-tried) - [] - let trySend (socket:Socket) flags frame = - use frame = new Frame(frame) - match C.zmq_msg_send(!!frame,!!socket,flags) with - | Okay -> true - | Busy -> false - | Fail -> ZMQ.error() - - let private waitToSend socket flags frame = - let rec send' () = - match trySend socket flags frame with - | true -> ((* okay *)) - | false -> send'() - send'() - - /// Sends a frame, indicating no more frames will follow - [] - let send socket frame = - frame |> waitToSend socket ZMQ.WAIT - - /// Sends a frame, indicating more frames will follow, - /// and returning the given socket - [] - let sendMore (socket:Socket) frame = - frame |> waitToSend socket ZMQ.SNDMORE - socket - - /// Operator equivalent to Socket.send - let (<<|) socket = send socket - /// Operator equivalent to Socket.sendMore - let (<~|) socket = sendMore socket - - /// Operator equivalent to Socket.send (with arguments reversed) - let (|>>) data socket = socket <<| data - /// Operator equivalent to Socket.sendMore (with arguments reversed) - let (|~>) data socket = socket <~| data - - /// Sends all frames of a given message - [] - let sendAll (socket:Socket) (message:#seq<_>) = - let last = (message |> Seq.length) - 1 - message - |> Seq.mapi (fun i msg -> if i = last then ((|>>) msg) - else ((|~>) msg) >> ignore) - |> Seq.iter (fun send' -> socket |> send') - -(* message receiving *) - - /// Gets the next available frame from a socket, returning option - /// where None indicates the operation should be re-attempted - [] - let tryRecv (socket:Socket) flags = - use frame = new Frame() - match C.zmq_msg_recv(!!frame,!!socket,flags) with - | Okay -> let mutable frame' = Array.empty - frame' <- frame.Data - Some(frame') - | Busy -> None - | Fail -> ZMQ.error() - - /// Waits for (and returns) the next available frame from a socket - [] - let recv socket = Option.get (tryRecv socket ZMQ.WAIT) - - /// Returns true if more message frames are available - [] - let recvMore socket = get socket ZMQ.RCVMORE - - /// Retrieves all frames of the next available message - [] - let recvAll socket = - [| yield socket |> recv - while socket |> recvMore do yield socket |> recv |] - - /// Copies a message frame-wise from one socket to another without - /// first marshalling the message part into the managed code space - [] - let transfer (socket:Socket) (target:Socket) = - use frame = new Frame() - let rec send' flags = - match C.zmq_msg_send(!!frame,!!target,flags) with - | Okay -> ((* pass *)) - | Busy -> send' flags - | Fail -> ZMQ.error() - let loop = ref true - while !loop do - match C.zmq_msg_recv(!!frame,!!socket,ZMQ.WAIT) with - | Okay -> loop := socket |> recvMore - send' (if !loop then ZMQ.SNDMORE else ZMQ.DONTWAIT) - | _ -> ZMQ.error() - - /// Operator equivalent to Socket.transfer - let (>|<) socket target = target |> transfer socket +(*------------------------------------------------------------------------- +Copyright (c) Paulmichael Blasucci. + +This source code is subject to terms and conditions of the Apache License, +Version 2.0. A copy of the license can be found in the License.html file +at the root of this distribution. + +By using this source code in any fashion, you are agreeing to be bound +by the terms of the Apache License, Version 2.0. + +You must not remove this notice, or any other, from this software. +-------------------------------------------------------------------------*) +namespace fszmq + +open System +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +/// Contains methods for working with Socket instances +[] +module Socket = + +(* connectivity *) + + /// Causes an endpoint to start accepting + /// connections at the given address + [] + let bind (socket:Socket) address = + let okay = C.zmq_bind(!!socket,address) + if okay <> 0 then ZMQ.error() + + /// Causes an endpoint to stop accepting + /// connections at the given address + [] + let unbind (socket:Socket) address = + let okay = C.zmq_unbind(!!socket,address) + if okay <> 0 then ZMQ.error() + + /// Connects to an endpoint to the given address + [] + let connect (socket:Socket) address = + let okay = C.zmq_connect(!!socket,address) + if okay <> 0 then ZMQ.error() + + /// Disconnects to an endpoint from the given address + [] + let disconnect (socket:Socket) address = + let okay = C.zmq_disconnect(!!socket,address) + if okay <> 0 then ZMQ.error() + +(* socket options *) + + /// Gets the value of the given option for the given Socket + [] + let get<'t> (socket:Socket) socketOption : 't = + let size,read = + let t = typeof<'t> + if t = typeof then 4,(snd >> readInt32 >> box) + elif t = typeof then 4,(snd >> readBool >> box) + elif t = typeof then 8,(snd >> readInt64 >> box) + elif t = typeof then 8,(snd >> readUInt64 >> box) + elif t = typeof then 255,( readString >> box) + elif t = typeof then 255,( readBytes >> box) + else invalidOp "Invalid data type" + let buffer = Marshal.AllocHGlobal(size) + try + let mutable size' = unativeint size + let okay = C.zmq_getsockopt(!!socket,socketOption,buffer,&size') + if okay <> 0 then ZMQ.error() + downcast read (size',buffer) + finally + Marshal.FreeHGlobal(buffer) + + /// Sets the given option value for the given Socket + [] + let set (socket:Socket) (socketOption,value:'t) = + let size,write = + match box value with + | :? (int32 ) as v -> sizeof,(writeInt32 v) + | :? (bool ) as v -> sizeof,(writeBool v) + | :? (int64 ) as v -> sizeof,(writeInt64 v) + | :? (uint64) as v -> sizeof,(writeUInt64 v) + | :? (string) as v -> v.Length ,(writeString v) + | :? (byte[]) as v -> v.Length ,(writeBytes v) + | _ -> invalidOp "Invalid data type" + let buffer = Marshal.AllocHGlobal(size) + try + write(buffer) + let okay = C.zmq_setsockopt(!!socket + ,socketOption + ,buffer + ,unativeint size) + if okay <> 0 then ZMQ.error() + finally + Marshal.FreeHGlobal(buffer) + + /// Sets the given block of option values for the given Socket + [] + let config socket (socketOptions: (int * obj) seq) = + let set' = set socket in socketOptions |> Seq.iter (set') + +(* subscripitions *) + + /// Adds one subscription for each of the given topics + [] + let subscribe socket topics = + let setter (t:byte[]) = set socket (ZMQ.SUBSCRIBE,t) |> ignore + topics |> Seq.iter setter + + /// Removes one subscription for each of the given topics + [] + let unsubscribe socket topics = + let setter (t:byte[]) = set socket (ZMQ.UNSUBSCRIBE,t) |> ignore + topics |> Seq.iter setter + +(* message sending *) + let private (|Okay|Busy|Fail|) = function + | -1 -> match C.zmq_errno() with + | ZMQ.EAGAIN -> Busy + | _ -> Fail + | _ -> Okay + + /// Sends a frame, with the given flags, returning true (or false) + /// if the send was successful (or should be re-tried) + [] + let trySend (socket:Socket) flags frame = + use frame = new Frame(frame) + match C.zmq_msg_send(!!frame,!!socket,flags) with + | Okay -> true + | Busy -> false + | Fail -> ZMQ.error() + + let private waitToSend socket flags frame = + let rec send' () = + match trySend socket flags frame with + | true -> ((* okay *)) + | false -> send'() + send'() + + /// Sends a frame, indicating no more frames will follow + [] + let send socket frame = + frame |> waitToSend socket ZMQ.WAIT + + /// Sends a frame, indicating more frames will follow, + /// and returning the given socket + [] + let sendMore (socket:Socket) frame = + frame |> waitToSend socket ZMQ.SNDMORE + socket + + /// Operator equivalent to Socket.send + let (<<|) socket = send socket + /// Operator equivalent to Socket.sendMore + let (<~|) socket = sendMore socket + + /// Operator equivalent to Socket.send (with arguments reversed) + let (|>>) data socket = socket <<| data + /// Operator equivalent to Socket.sendMore (with arguments reversed) + let (|~>) data socket = socket <~| data + + /// Sends all frames of a given message + [] + let sendAll (socket:Socket) (message:#seq<_>) = + let last = (message |> Seq.length) - 1 + message + |> Seq.mapi (fun i msg -> if i = last then ((|>>) msg) + else ((|~>) msg) >> ignore) + |> Seq.iter (fun send' -> socket |> send') + +(* message receiving *) + + /// Gets the next available frame from a socket, returning option + /// where None indicates the operation should be re-attempted + [] + let tryRecv (socket:Socket) flags = + use frame = new Frame() + match C.zmq_msg_recv(!!frame,!!socket,flags) with + | Okay -> let mutable frame' = Array.empty + frame' <- frame.Data + Some(frame') + | Busy -> None + | Fail -> ZMQ.error() + + /// Waits for (and returns) the next available frame from a socket + [] + let recv socket = Option.get (tryRecv socket ZMQ.WAIT) + + /// Returns true if more message frames are available + [] + let recvMore socket = get socket ZMQ.RCVMORE + + /// Retrieves all frames of the next available message + [] + let recvAll socket = + [| yield socket |> recv + while socket |> recvMore do yield socket |> recv |] + + /// Copies a message frame-wise from one socket to another without + /// first marshalling the message part into the managed code space + [] + let transfer (socket:Socket) (target:Socket) = + use frame = new Frame() + let rec send' flags = + match C.zmq_msg_send(!!frame,!!target,flags) with + | Okay -> ((* pass *)) + | Busy -> send' flags + | Fail -> ZMQ.error() + let loop = ref true + while !loop do + match C.zmq_msg_recv(!!frame,!!socket,ZMQ.WAIT) with + | Okay -> loop := socket |> recvMore + send' (if !loop then ZMQ.SNDMORE else ZMQ.DONTWAIT) + | _ -> ZMQ.error() + + /// Operator equivalent to Socket.transfer + let (>|<) socket target = target |> transfer socket diff --git a/fszmq/fszmq.fsproj b/src/fszmq/fszmq.fsproj similarity index 75% rename from fszmq/fszmq.fsproj rename to src/fszmq/fszmq.fsproj index bf566c0..7933396 100644 --- a/fszmq/fszmq.fsproj +++ b/src/fszmq/fszmq.fsproj @@ -9,9 +9,11 @@ Library fszmq fszmq - v4.5 + v4.0 fszmq + 4.3.1.0 + 11 true @@ -27,10 +29,10 @@ pdbonly true true - ..\bin\ + ..\..\bin\ TRACE 3 - ..\bin\fszmq.xml + ..\..\bin\fszmq.xml true @@ -47,10 +49,10 @@ pdbonly true true - ..\bin\ + ..\..\bin\ TRACE 3 - ..\bin\fszmq.xml + ..\..\bin\fszmq.xml x64 @@ -68,13 +70,25 @@ pdbonly true true - ..\bin\ + ..\..\bin\ TRACE 3 - ..\bin\fszmq.xml + ..\..\bin\fszmq.xml x86 - + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + @@ -88,11 +102,10 @@ - - - False - False + + True + diff --git a/fszmq.compat.cs/App.config b/tests/fszmq.compat.cs/App.config similarity index 60% rename from fszmq.compat.cs/App.config rename to tests/fszmq.compat.cs/App.config index 8e15646..74ade9d 100644 --- a/fszmq.compat.cs/App.config +++ b/tests/fszmq.compat.cs/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/fszmq.compat.cs/Program.cs b/tests/fszmq.compat.cs/Program.cs similarity index 97% rename from fszmq.compat.cs/Program.cs rename to tests/fszmq.compat.cs/Program.cs index f82f45a..e8cd16e 100644 --- a/fszmq.compat.cs/Program.cs +++ b/tests/fszmq.compat.cs/Program.cs @@ -1,23 +1,23 @@ -/*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*/ -using System; - -namespace fszmq.compat.cs -{ - class Program - { - static void Main(String[] args) - { - } - } -} +/*------------------------------------------------------------------------- +Copyright (c) Paulmichael Blasucci. + +This source code is subject to terms and conditions of the Apache License, +Version 2.0. A copy of the license can be found in the License.html file +at the root of this distribution. + +By using this source code in any fashion, you are agreeing to be bound +by the terms of the Apache License, Version 2.0. + +You must not remove this notice, or any other, from this software. +-------------------------------------------------------------------------*/ +using System; + +namespace fszmq.compat.cs +{ + class Program + { + static void Main(String[] args) + { + } + } +} diff --git a/fszmq.compat.cs/Properties/AssemblyInfo.cs b/tests/fszmq.compat.cs/Properties/AssemblyInfo.cs similarity index 98% rename from fszmq.compat.cs/Properties/AssemblyInfo.cs rename to tests/fszmq.compat.cs/Properties/AssemblyInfo.cs index b1abb76..890628f 100644 --- a/fszmq.compat.cs/Properties/AssemblyInfo.cs +++ b/tests/fszmq.compat.cs/Properties/AssemblyInfo.cs @@ -1,48 +1,48 @@ -/*------------------------------------------------------------------------- -Copyright (c) Paulmichael Blasucci. - -This source code is subject to terms and conditions of the Apache License, -Version 2.0. A copy of the license can be found in the License.html file -at the root of this distribution. - -By using this source code in any fashion, you are agreeing to be bound -by the terms of the Apache License, Version 2.0. - -You must not remove this notice, or any other, from this software. --------------------------------------------------------------------------*/ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("fszmq.compat.cs")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Bayard Rock")] -[assembly: AssemblyProduct("fszmq.compat.cs")] -[assembly: AssemblyCopyright("Copyright © Bayard Rock 2012")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ea5c64a0-f079-4a9b-a60a-3e901f3b8e65")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +/*------------------------------------------------------------------------- +Copyright (c) Paulmichael Blasucci. + +This source code is subject to terms and conditions of the Apache License, +Version 2.0. A copy of the license can be found in the License.html file +at the root of this distribution. + +By using this source code in any fashion, you are agreeing to be bound +by the terms of the Apache License, Version 2.0. + +You must not remove this notice, or any other, from this software. +-------------------------------------------------------------------------*/ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("fszmq.compat.cs")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Bayard Rock")] +[assembly: AssemblyProduct("fszmq.compat.cs")] +[assembly: AssemblyCopyright("Copyright © Bayard Rock 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ea5c64a0-f079-4a9b-a60a-3e901f3b8e65")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/fszmq.compat.cs/fszmq.compat.cs.csproj b/tests/fszmq.compat.cs/fszmq.compat.cs.csproj similarity index 93% rename from fszmq.compat.cs/fszmq.compat.cs.csproj rename to tests/fszmq.compat.cs/fszmq.compat.cs.csproj index eee298f..a548487 100644 --- a/fszmq.compat.cs/fszmq.compat.cs.csproj +++ b/tests/fszmq.compat.cs/fszmq.compat.cs.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,8 +9,9 @@ Properties fszmq.compat.cs fszmq.compat.cs - v4.5 + v4.0 512 + AnyCPU @@ -88,13 +89,13 @@ - + libzmq.dll PreserveNewest - + {d0f2cdeb-3d9c-4fe6-bef9-27b9c7f0cf71} fszmq diff --git a/fszmq.compat.vb/App.config b/tests/fszmq.compat.vb/App.config similarity index 60% rename from fszmq.compat.vb/App.config rename to tests/fszmq.compat.vb/App.config index 8e15646..74ade9d 100644 --- a/fszmq.compat.vb/App.config +++ b/tests/fszmq.compat.vb/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/fszmq.compat.vb/My Project/Application.Designer.vb b/tests/fszmq.compat.vb/My Project/Application.Designer.vb similarity index 88% rename from fszmq.compat.vb/My Project/Application.Designer.vb rename to tests/fszmq.compat.vb/My Project/Application.Designer.vb index 4aacd27..427ae7b 100644 --- a/fszmq.compat.vb/My Project/Application.Designer.vb +++ b/tests/fszmq.compat.vb/My Project/Application.Designer.vb @@ -1,13 +1,13 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.18010 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.18408 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/fszmq.compat.vb/My Project/Application.myapp b/tests/fszmq.compat.vb/My Project/Application.myapp similarity index 97% rename from fszmq.compat.vb/My Project/Application.myapp rename to tests/fszmq.compat.vb/My Project/Application.myapp index a97d78a..048bdce 100644 --- a/fszmq.compat.vb/My Project/Application.myapp +++ b/tests/fszmq.compat.vb/My Project/Application.myapp @@ -1,22 +1,22 @@ - - - - false - false - 0 - true - 0 - 2 - true - + + + + false + false + 0 + true + 0 + 2 + true + diff --git a/fszmq.compat.vb/My Project/AssemblyInfo.vb b/tests/fszmq.compat.vb/My Project/AssemblyInfo.vb similarity index 97% rename from fszmq.compat.vb/My Project/AssemblyInfo.vb rename to tests/fszmq.compat.vb/My Project/AssemblyInfo.vb index 24b241f..0daf060 100644 --- a/fszmq.compat.vb/My Project/AssemblyInfo.vb +++ b/tests/fszmq.compat.vb/My Project/AssemblyInfo.vb @@ -1,48 +1,48 @@ -'-------------------------------------------------------------------------- -'Copyright (c) Paulmichael Blasucci. -' -'This source code is subject to terms and conditions of the Apache License, -'Version 2.0. A copy of the license can be found in the License.html file -'at the root of this distribution. -' -'By using this source code in any fashion, you are agreeing to be bound -'by the terms of the Apache License, Version 2.0. -' -'You must not remove this notice, or any other, from this software. -'-------------------------------------------------------------------------- - -Imports System -Imports System.Reflection -Imports System.Runtime.InteropServices - -' General Information about an assembly is controlled through the following -' set of attributes. Change these attribute values to modify the information -' associated with an assembly. - -' Review the values of the assembly attributes - - - - - - - - - - -'The following GUID is for the ID of the typelib if this project is exposed to COM - - -' Version information for an assembly consists of the following four values: -' -' Major Version -' Minor Version -' Build Number -' Revision -' -' You can specify all the values or you can default the Build and Revision Numbers -' by using the '*' as shown below: -' - - - +'-------------------------------------------------------------------------- +'Copyright (c) Paulmichael Blasucci. +' +'This source code is subject to terms and conditions of the Apache License, +'Version 2.0. A copy of the license can be found in the License.html file +'at the root of this distribution. +' +'By using this source code in any fashion, you are agreeing to be bound +'by the terms of the Apache License, Version 2.0. +' +'You must not remove this notice, or any other, from this software. +'-------------------------------------------------------------------------- + +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/fszmq.compat.vb/My Project/Resources.Designer.vb b/tests/fszmq.compat.vb/My Project/Resources.Designer.vb similarity index 83% rename from fszmq.compat.vb/My Project/Resources.Designer.vb rename to tests/fszmq.compat.vb/My Project/Resources.Designer.vb index 7b11903..acbacf6 100644 --- a/fszmq.compat.vb/My Project/Resources.Designer.vb +++ b/tests/fszmq.compat.vb/My Project/Resources.Designer.vb @@ -1,7 +1,7 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:4.0.30319.17929 +' Runtime Version:4.0.30319.18408 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. @@ -11,6 +11,7 @@ Option Strict On Option Explicit On +Imports System Namespace My.Resources @@ -21,20 +22,20 @@ Namespace My.Resources ''' ''' A strongly-typed resource class, for looking up localized strings, etc. ''' - _ + _ Friend Module Resources - + Private resourceMan As Global.System.Resources.ResourceManager - + Private resourceCulture As Global.System.Globalization.CultureInfo - + ''' ''' Returns the cached ResourceManager instance used by this class. ''' - _ + _ Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager Get If Object.ReferenceEquals(resourceMan, Nothing) Then @@ -44,17 +45,17 @@ Namespace My.Resources Return resourceMan End Get End Property - + ''' ''' Overrides the current thread's CurrentUICulture property for all ''' resource lookups using this strongly typed resource class. ''' - _ + _ Friend Property Culture() As Global.System.Globalization.CultureInfo Get Return resourceCulture End Get - Set(ByVal value As Global.System.Globalization.CultureInfo) + Set resourceCulture = value End Set End Property diff --git a/fszmq.compat.vb/My Project/Resources.resx b/tests/fszmq.compat.vb/My Project/Resources.resx similarity index 100% rename from fszmq.compat.vb/My Project/Resources.resx rename to tests/fszmq.compat.vb/My Project/Resources.resx diff --git a/fszmq.compat.vb/My Project/Settings.Designer.vb b/tests/fszmq.compat.vb/My Project/Settings.Designer.vb similarity index 62% rename from fszmq.compat.vb/My Project/Settings.Designer.vb rename to tests/fszmq.compat.vb/My Project/Settings.Designer.vb index 7939758..ce83437 100644 --- a/fszmq.compat.vb/My Project/Settings.Designer.vb +++ b/tests/fszmq.compat.vb/My Project/Settings.Designer.vb @@ -1,7 +1,7 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:4.0.30319.17929 +' Runtime Version:4.0.30319.18408 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. @@ -13,42 +13,42 @@ Option Explicit On Namespace My - - _ + + _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) - + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + #Region "My.Settings Auto-Save Functionality" #If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean + Private Shared addedHandler As Boolean - Private Shared addedHandlerLockObject As New Object + Private Shared addedHandlerLockObject As New Object - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub #End If #End Region - + Public Shared ReadOnly Property [Default]() As MySettings Get - + #If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If #End If Return defaultInstance End Get diff --git a/fszmq.compat.vb/My Project/Settings.settings b/tests/fszmq.compat.vb/My Project/Settings.settings similarity index 100% rename from fszmq.compat.vb/My Project/Settings.settings rename to tests/fszmq.compat.vb/My Project/Settings.settings diff --git a/fszmq.compat.vb/Program.vb b/tests/fszmq.compat.vb/Program.vb similarity index 97% rename from fszmq.compat.vb/Program.vb rename to tests/fszmq.compat.vb/Program.vb index f5b55c9..ce23507 100644 --- a/fszmq.compat.vb/Program.vb +++ b/tests/fszmq.compat.vb/Program.vb @@ -1,19 +1,19 @@ -'-------------------------------------------------------------------------- -'Copyright (c) Paulmichael Blasucci. -' -'This source code is subject to terms and conditions of the Apache License, -'Version 2.0. A copy of the license can be found in the License.html file -'at the root of this distribution. -' -'By using this source code in any fashion, you are agreeing to be bound -'by the terms of the Apache License, Version 2.0. -' -'You must not remove this notice, or any other, from this software. -'-------------------------------------------------------------------------- -Module Program - - Sub Main() - - End Sub - -End Module +'-------------------------------------------------------------------------- +'Copyright (c) Paulmichael Blasucci. +' +'This source code is subject to terms and conditions of the Apache License, +'Version 2.0. A copy of the license can be found in the License.html file +'at the root of this distribution. +' +'By using this source code in any fashion, you are agreeing to be bound +'by the terms of the Apache License, Version 2.0. +' +'You must not remove this notice, or any other, from this software. +'-------------------------------------------------------------------------- +Module Program + + Sub Main() + + End Sub + +End Module diff --git a/fszmq.compat.vb/fszmq.compat.vb.vbproj b/tests/fszmq.compat.vb/fszmq.compat.vb.vbproj similarity index 95% rename from fszmq.compat.vb/fszmq.compat.vb.vbproj rename to tests/fszmq.compat.vb/fszmq.compat.vb.vbproj index c9a5386..00825c4 100644 --- a/fszmq.compat.vb/fszmq.compat.vb.vbproj +++ b/tests/fszmq.compat.vb/fszmq.compat.vb.vbproj @@ -1,5 +1,5 @@  - + Debug @@ -11,7 +11,8 @@ fszmq.compat.vb 512 Console - v4.5 + v4.0 + AnyCPU @@ -150,13 +151,13 @@ - + libzmq.dll PreserveNewest - + {d0f2cdeb-3d9c-4fe6-bef9-27b9c7f0cf71} fszmq diff --git a/tests/fszmq.inproc_throughput/App.config b/tests/fszmq.inproc_throughput/App.config new file mode 100644 index 0000000..ef730a5 --- /dev/null +++ b/tests/fszmq.inproc_throughput/App.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fszmq.inproc_throughput/Native.fs b/tests/fszmq.inproc_throughput/Native.fs similarity index 100% rename from fszmq.inproc_throughput/Native.fs rename to tests/fszmq.inproc_throughput/Native.fs diff --git a/fszmq.inproc_throughput/Program.fs b/tests/fszmq.inproc_throughput/Program.fs similarity index 100% rename from fszmq.inproc_throughput/Program.fs rename to tests/fszmq.inproc_throughput/Program.fs diff --git a/fszmq.inproc_throughput/fszmq.perf.inproc_thr.fsproj b/tests/fszmq.inproc_throughput/fszmq.perf.inproc_thr.fsproj similarity index 65% rename from fszmq.inproc_throughput/fszmq.perf.inproc_thr.fsproj rename to tests/fszmq.inproc_throughput/fszmq.perf.inproc_thr.fsproj index 70a7c7f..009017f 100644 --- a/fszmq.inproc_throughput/fszmq.perf.inproc_thr.fsproj +++ b/tests/fszmq.inproc_throughput/fszmq.perf.inproc_thr.fsproj @@ -9,8 +9,10 @@ Exe fszmq.inproc_throughput inproc_thr - v4.5 + v4.0 fszmq.perf.inproc_thr + 4.3.1.0 + true @@ -36,10 +38,10 @@ true - - + True + @@ -48,13 +50,13 @@ - + libzmq.dll PreserveNewest - + fszmq {d0f2cdeb-3d9c-4fe6-bef9-27b9c7f0cf71} True @@ -87,7 +89,43 @@ true x64 - + + true + full + false + false + bin\Debug\ + DEBUG;TRACE + 3 + bin\Debug\fszmq.inproc_throughput.XML + true + 1024 1000000 + x86 + + + pdbonly + true + true + bin\Release\ + TRACE + 3 + bin\Release\fszmq.inproc_throughput.XML + true + x86 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + \ No newline at end of file diff --git a/tests/fszmq.tests/packages.config b/tests/fszmq.tests/packages.config new file mode 100644 index 0000000..4a8a25d --- /dev/null +++ b/tests/fszmq.tests/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/zeromq/.gitignore b/zeromq/.gitignore deleted file mode 100644 index 3bd2909..0000000 --- a/zeromq/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# ignore zeromq files, these are for local use only -*.*