Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

working dotnet bindings addressing memory issues

  • Loading branch information...
commit 5311ae33bcfe8a33b6c9bf9fcbeacb57902f6d96 1 parent b660082
John Murphy authored

Showing 31 changed files with 497 additions and 549 deletions. Show diff stats Hide diff stats

  1. +33 0 bindings/dotnet/README.txt
  2. BIN  bindings/dotnet/deps/czmq/lib/czmq.lib
  3. BIN  bindings/dotnet/deps/libmdp/bin/libmdp.dll
  4. BIN  bindings/dotnet/deps/libmdp/lib/libmdp.lib
  5. +33 23 bindings/dotnet/dotnet.sln
  6. +15 13 bindings/dotnet/{zeromq.majordomo → mdpwrapper}/ReadMe.txt
  7. +19 0 bindings/dotnet/mdpwrapper/dllmain.cpp
  8. +75 0 bindings/dotnet/mdpwrapper/mdpwrapper.cpp
  9. +35 0 bindings/dotnet/mdpwrapper/mdpwrapper.h
  10. +39 33 bindings/dotnet/{zeromq.majordomo/zeromq.majordomo.vcxproj → mdpwrapper/mdpwrapper.vcxproj}
  11. +9 17 ...ngs/dotnet/{zeromq.majordomo/zeromq.majordomo.vcxproj.filters → mdpwrapper/mdpwrapper.vcxproj.filters}
  12. +4 1 bindings/dotnet/{zeromq.majordomo/Stdafx.cpp → mdpwrapper/stdafx.cpp}
  13. +16 0 bindings/dotnet/mdpwrapper/stdafx.h
  14. +8 0 bindings/dotnet/mdpwrapper/targetver.h
  15. +122 0 bindings/dotnet/zeromq.majordomo.csharp/Client.cs
  16. +3 3 ...ings/dotnet/{zeromq.majordomo.test.workerconsole → zeromq.majordomo.csharp}/Properties/AssemblyInfo.cs
  17. +44 0 bindings/dotnet/zeromq.majordomo.csharp/Response.cs
  18. +11 19 ...e/zeromq.majordomo.test.workerconsole.csproj → zeromq.majordomo.csharp/zeromq.majordomo.csharp.csproj}
  19. +0 25 bindings/dotnet/zeromq.majordomo.test.workerconsole/Program.cs
  20. +16 8 bindings/dotnet/zeromq.majordomo.testclient/Program.cs
  21. +9 5 bindings/dotnet/zeromq.majordomo.testclient/zeromq.majordomo.test.clientconsole.csproj
  22. +0 40 bindings/dotnet/zeromq.majordomo/AssemblyInfo.cpp
  23. +0 7 bindings/dotnet/zeromq.majordomo/Stdafx.h
  24. BIN  bindings/dotnet/zeromq.majordomo/app.ico
  25. BIN  bindings/dotnet/zeromq.majordomo/app.rc
  26. +0 21 bindings/dotnet/zeromq.majordomo/mdp_wrapper.cpp
  27. +0 8 bindings/dotnet/zeromq.majordomo/mdp_wrapper.h
  28. +0 3  bindings/dotnet/zeromq.majordomo/resource.h
  29. +0 252 bindings/dotnet/zeromq.majordomo/zeromq.majordomo.cpp
  30. +0 66 bindings/dotnet/zeromq.majordomo/zeromq.majordomo.h
  31. +6 5 builds/msvc/libmdp/libmdp.vcxproj
33 bindings/dotnet/README.txt
... ... @@ -0,0 +1,33 @@
  1 +.NET Bindings for MajorDomo Client
  2 +
  3 +Dependencies
  4 +-------------------------------
  5 +mdpwrapper depends on zeromq, libmdp and czmq. The libraries and header files for these dependencies
  6 +are in the deps directory under the solution directory.
  7 +
  8 +Projects
  9 +------------------------------
  10 +mdpwrapper is a Windows DLL that wraps libmdp so that we can use some of libmdp's opaque functions
  11 +that would not be available to us in the managed environment.
  12 +
  13 +zeromq.majordomo.csharp is the assembly that provides a facade of the majordomo client. You would
  14 +create an application include a reference to zeromq.majordomo.csharp and go to town. Note that
  15 +libzmq.dll libmdp.dll and mdpwrapper.dll have to be in your applications search path.
  16 +
  17 +Usage Example:
  18 +
  19 +// instantiates client, sends a message and cleans up
  20 +using( Client c = new Client( "tcp://192.168.1.7:5555" ) )
  21 +{
  22 + c.Send( "my service", "I like cheese" );
  23 + Response r = c.Recv();
  24 +
  25 + if( r != null )
  26 + {
  27 + r.Print();
  28 + }
  29 +
  30 +}
  31 +
  32 +zeromq.majordomo.test.clientconsole is an application to test the zeromq.majordomo.csharp assembly
  33 +
BIN  bindings/dotnet/deps/czmq/lib/czmq.lib
Binary file not shown
BIN  bindings/dotnet/deps/libmdp/bin/libmdp.dll
Binary file not shown
BIN  bindings/dotnet/deps/libmdp/lib/libmdp.lib
Binary file not shown
56 bindings/dotnet/dotnet.sln
... ... @@ -1,52 +1,62 @@
1 1 
2 2 Microsoft Visual Studio Solution File, Format Version 11.00
3 3 # Visual Studio 2010
4   -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zeromq.majordomo", "zeromq.majordomo\zeromq.majordomo.vcxproj", "{B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}"
5   -EndProject
6 4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "zeromq.majordomo.test.clientconsole", "zeromq.majordomo.testclient\zeromq.majordomo.test.clientconsole.csproj", "{0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}"
7 5 EndProject
8   -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "zeromq.majordomo.test.workerconsole", "zeromq.majordomo.test.workerconsole\zeromq.majordomo.test.workerconsole.csproj", "{2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}"
  6 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "zeromq.majordomo.csharp", "zeromq.majordomo.csharp\zeromq.majordomo.csharp.csproj", "{19176FD4-132B-4F17-B50C-2D9AD4D15435}"
  7 +EndProject
  8 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mdpwrapper", "mdpwrapper\mdpwrapper.vcxproj", "{152BBA96-1220-4373-B993-5CD5CA151E62}"
  9 +EndProject
  10 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2248B071-394A-4611-B1CE-3E024EFCD41B}"
9 11 EndProject
10 12 Global
11 13 GlobalSection(SolutionConfigurationPlatforms) = preSolution
  14 + Debug|Any CPU = Debug|Any CPU
12 15 Debug|Mixed Platforms = Debug|Mixed Platforms
13 16 Debug|Win32 = Debug|Win32
14 17 Debug|x86 = Debug|x86
  18 + Release|Any CPU = Release|Any CPU
15 19 Release|Mixed Platforms = Release|Mixed Platforms
16 20 Release|Win32 = Release|Win32
17 21 Release|x86 = Release|x86
18 22 EndGlobalSection
19 23 GlobalSection(ProjectConfigurationPlatforms) = postSolution
20   - {B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
21   - {B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}.Debug|Mixed Platforms.Build.0 = Debug|Win32
22   - {B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}.Debug|Win32.ActiveCfg = Debug|Win32
23   - {B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}.Debug|Win32.Build.0 = Debug|Win32
24   - {B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}.Debug|x86.ActiveCfg = Debug|Win32
25   - {B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}.Release|Mixed Platforms.ActiveCfg = Release|Win32
26   - {B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}.Release|Mixed Platforms.Build.0 = Release|Win32
27   - {B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}.Release|Win32.ActiveCfg = Release|Win32
28   - {B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}.Release|Win32.Build.0 = Release|Win32
29   - {B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}.Release|x86.ActiveCfg = Release|Win32
  24 + {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Debug|Any CPU.ActiveCfg = Debug|x86
30 25 {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
31 26 {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Debug|Mixed Platforms.Build.0 = Debug|x86
32 27 {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Debug|Win32.ActiveCfg = Debug|x86
33 28 {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Debug|x86.ActiveCfg = Debug|x86
34 29 {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Debug|x86.Build.0 = Debug|x86
  30 + {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Release|Any CPU.ActiveCfg = Release|x86
35 31 {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Release|Mixed Platforms.ActiveCfg = Release|x86
36 32 {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Release|Mixed Platforms.Build.0 = Release|x86
37 33 {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Release|Win32.ActiveCfg = Release|x86
38 34 {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Release|x86.ActiveCfg = Release|x86
39 35 {0B1F4A9C-6356-4E3C-B1E2-329B9832FAFF}.Release|x86.Build.0 = Release|x86
40   - {2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
41   - {2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}.Debug|Mixed Platforms.Build.0 = Debug|x86
42   - {2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}.Debug|Win32.ActiveCfg = Debug|x86
43   - {2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}.Debug|x86.ActiveCfg = Debug|x86
44   - {2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}.Debug|x86.Build.0 = Debug|x86
45   - {2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}.Release|Mixed Platforms.ActiveCfg = Release|x86
46   - {2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}.Release|Mixed Platforms.Build.0 = Release|x86
47   - {2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}.Release|Win32.ActiveCfg = Release|x86
48   - {2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}.Release|x86.ActiveCfg = Release|x86
49   - {2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}.Release|x86.Build.0 = Release|x86
  36 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  37 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Debug|Any CPU.Build.0 = Debug|Any CPU
  38 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
  39 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
  40 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Debug|Win32.ActiveCfg = Debug|Any CPU
  41 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Debug|x86.ActiveCfg = Debug|Any CPU
  42 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Release|Any CPU.ActiveCfg = Release|Any CPU
  43 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Release|Any CPU.Build.0 = Release|Any CPU
  44 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
  45 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Release|Mixed Platforms.Build.0 = Release|Any CPU
  46 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Release|Win32.ActiveCfg = Release|Any CPU
  47 + {19176FD4-132B-4F17-B50C-2D9AD4D15435}.Release|x86.ActiveCfg = Release|Any CPU
  48 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Debug|Any CPU.ActiveCfg = Debug|Win32
  49 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
  50 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Debug|Mixed Platforms.Build.0 = Debug|Win32
  51 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Debug|Win32.ActiveCfg = Debug|Win32
  52 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Debug|Win32.Build.0 = Debug|Win32
  53 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Debug|x86.ActiveCfg = Debug|Win32
  54 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Release|Any CPU.ActiveCfg = Release|Win32
  55 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Release|Mixed Platforms.ActiveCfg = Release|Win32
  56 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Release|Mixed Platforms.Build.0 = Release|Win32
  57 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Release|Win32.ActiveCfg = Release|Win32
  58 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Release|Win32.Build.0 = Release|Win32
  59 + {152BBA96-1220-4373-B993-5CD5CA151E62}.Release|x86.ActiveCfg = Release|Win32
50 60 EndGlobalSection
51 61 GlobalSection(SolutionProperties) = preSolution
52 62 HideSolutionNode = FALSE
28 bindings/dotnet/zeromq.majordomo/ReadMe.txt → bindings/dotnet/mdpwrapper/ReadMe.txt
... ... @@ -1,38 +1,40 @@
1 1 ========================================================================
2   - DYNAMIC LINK LIBRARY : zeromq.majordomo Project Overview
  2 + DYNAMIC LINK LIBRARY : mdpwrapper Project Overview
3 3 ========================================================================
4 4
5   -AppWizard has created this zeromq.majordomo DLL for you.
  5 +AppWizard has created this mdpwrapper DLL for you.
6 6
7 7 This file contains a summary of what you will find in each of the files that
8   -make up your zeromq.majordomo application.
  8 +make up your mdpwrapper application.
9 9
10   -zeromq.majordomo.vcxproj
11   - This is the main project file for VC++ projects generated using an Application Wizard.
12   - It contains information about the version of Visual C++ that generated the file, and
  10 +
  11 +mdpwrapper.vcxproj
  12 + This is the main project file for VC++ projects generated using an Application Wizard.
  13 + It contains information about the version of Visual C++ that generated the file, and
13 14 information about the platforms, configurations, and project features selected with the
14 15 Application Wizard.
15 16
16   -zeromq.majordomo.vcxproj.filters
  17 +mdpwrapper.vcxproj.filters
17 18 This is the filters file for VC++ projects generated using an Application Wizard.
18 19 It contains information about the association between the files in your project
19 20 and the filters. This association is used in the IDE to show grouping of files with
20 21 similar extensions under a specific node (for e.g. ".cpp" files are associated with the
21 22 "Source Files" filter).
22 23
23   -zeromq.majordomo.cpp
  24 +mdpwrapper.cpp
24 25 This is the main DLL source file.
25 26
26   -zeromq.majordomo.h
27   - This file contains a class declaration.
  27 +/////////////////////////////////////////////////////////////////////////////
  28 +Other standard files:
28 29
29   -AssemblyInfo.cpp
30   - Contains custom attributes for modifying assembly metadata.
  30 +StdAfx.h, StdAfx.cpp
  31 + These files are used to build a precompiled header (PCH) file
  32 + named mdpwrapper.pch and a precompiled types file named StdAfx.obj.
31 33
32 34 /////////////////////////////////////////////////////////////////////////////
33 35 Other notes:
34 36
35   -AppWizard uses "TODO:" to indicate parts of the source code you
  37 +AppWizard uses "TODO:" comments to indicate parts of the source code you
36 38 should add to or customize.
37 39
38 40 /////////////////////////////////////////////////////////////////////////////
19 bindings/dotnet/mdpwrapper/dllmain.cpp
... ... @@ -0,0 +1,19 @@
  1 +// dllmain.cpp : Defines the entry point for the DLL application.
  2 +#include "stdafx.h"
  3 +
  4 +BOOL APIENTRY DllMain( HMODULE hModule,
  5 + DWORD ul_reason_for_call,
  6 + LPVOID lpReserved
  7 + )
  8 +{
  9 + switch (ul_reason_for_call)
  10 + {
  11 + case DLL_PROCESS_ATTACH:
  12 + case DLL_THREAD_ATTACH:
  13 + case DLL_THREAD_DETACH:
  14 + case DLL_PROCESS_DETACH:
  15 + break;
  16 + }
  17 + return TRUE;
  18 +}
  19 +
75 bindings/dotnet/mdpwrapper/mdpwrapper.cpp
... ... @@ -0,0 +1,75 @@
  1 +// mdpwrapper.cpp : Defines the exported functions for the DLL application.
  2 +//
  3 +
  4 +#include "stdafx.h"
  5 +#include "mdpwrapper.h"
  6 +
  7 +
  8 +
  9 +
  10 +mdp_client_t * client_new (char *broker, int verbose)
  11 +{
  12 + return mdp_client_new( broker, verbose );
  13 +}
  14 +
  15 +void client_destroy (mdp_client_t **self_p)
  16 +{
  17 + mdp_client_destroy( self_p );
  18 +}
  19 +
  20 +void client_set_timeout (mdp_client_t *self, int timeout)
  21 +{
  22 + mdp_client_set_timeout( self, timeout );
  23 +}
  24 +
  25 +
  26 +int client_setsockopt (mdp_client_t *self, int option, const void *optval, size_t optvallen)
  27 +{
  28 + return mdp_client_setsockopt( self, option, optval, optvallen );
  29 +}
  30 +
  31 +int client_getsockopt (mdp_client_t *self, int option, void *optval, size_t *optvallen)
  32 +{
  33 + return mdp_client_getsockopt( self, option, optval, optvallen );
  34 +}
  35 +
  36 +void client_send_data (mdp_client_t *self, char *service, char *data, int size )
  37 +{
  38 + zmsg_t* zmsg = zmsg_new();
  39 + zmsg_addmem( zmsg, data, size );
  40 + mdp_client_send( self, service, &zmsg );
  41 +}
  42 +
  43 +
  44 +void client_send_string( mdp_client_t *self, char *service, char *msg )
  45 +{
  46 + zmsg_t* zmsg = zmsg_new();
  47 + zmsg_addstr( zmsg, msg );
  48 + mdp_client_send( self, service, &zmsg );
  49 +}
  50 +
  51 +
  52 +void client_recv (mdp_client_t *self, char **service_p, char **response_p )
  53 +{
  54 + *response_p = NULL;
  55 + zmsg_t* reply = mdp_client_recv( self, service_p );
  56 + if( reply ) {
  57 + size_t buffer_size = zmsg_content_size( reply ) + 1;
  58 + *response_p = (char*)malloc( buffer_size );
  59 + memset( *response_p, 0, buffer_size );
  60 +
  61 + char* p = *response_p;
  62 +
  63 + while(true) {
  64 + zframe_t* frame = zmsg_pop( reply );
  65 + if( frame ) {
  66 + size_t frame_size = zframe_size(frame);
  67 + memcpy( p, zframe_data(frame), frame_size );
  68 + p += frame_size;
  69 + zframe_destroy(&frame);
  70 + } else {
  71 + break;
  72 + }
  73 + }
  74 + }
  75 +}
35 bindings/dotnet/mdpwrapper/mdpwrapper.h
... ... @@ -0,0 +1,35 @@
  1 +// The following ifdef block is the standard way of creating macros which make exporting
  2 +// from a DLL simpler. All files within this DLL are compiled with the MDPWRAPPER_EXPORTS
  3 +// symbol defined on the command line. This symbol should not be defined on any project
  4 +// that uses this DLL. This way any other project whose source files include this file see
  5 +// MDPWRAPPER_API functions as being imported from a DLL, whereas this DLL sees symbols
  6 +// defined with this macro as being exported.
  7 +#ifdef MDPWRAPPER_EXPORTS
  8 +#define MDPWRAPPER_API __declspec(dllexport)
  9 +#else
  10 +#define MDPWRAPPER_API __declspec(dllimport)
  11 +#endif
  12 +
  13 +/*
  14 +class MDPWRAPPER_API Cmdpwrapper {
  15 +public:
  16 + Cmdpwrapper(void);
  17 + // TODO: add your methods here.
  18 +};
  19 +
  20 +extern MDPWRAPPER_API int nmdpwrapper;
  21 +*/
  22 +#include <mdp.h>
  23 +
  24 +//MDPWRAPPER_API int fnmdpwrapper(void);
  25 +
  26 +
  27 +
  28 +MDPWRAPPER_API mdp_client_t * client_new (char *broker, int verbose);
  29 +MDPWRAPPER_API void client_destroy (mdp_client_t **self_p);
  30 +MDPWRAPPER_API void client_set_timeout (mdp_client_t *self, int timeout);
  31 +MDPWRAPPER_API int client_setsockopt (mdp_client_t *self, int option, const void *optval, size_t optvallen);
  32 +MDPWRAPPER_API int client_getsockopt (mdp_client_t *self, int option, void *optval, size_t *optvallen);
  33 +MDPWRAPPER_API void client_send_data (mdp_client_t *self, char *service, char *data, int size );
  34 +MDPWRAPPER_API void client_send_string (mdp_client_t *self, char *service, char *msg );
  35 +MDPWRAPPER_API void client_recv (mdp_client_t *self, char **service_p, char **response_p);
72 .../dotnet/zeromq.majordomo/zeromq.majordomo.vcxproj → bindings/dotnet/mdpwrapper/mdpwrapper.vcxproj
@@ -11,22 +11,20 @@
11 11 </ProjectConfiguration>
12 12 </ItemGroup>
13 13 <PropertyGroup Label="Globals">
14   - <ProjectGuid>{B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}</ProjectGuid>
15   - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
16   - <Keyword>ManagedCProj</Keyword>
17   - <RootNamespace>zeromqmajordomo</RootNamespace>
  14 + <ProjectGuid>{152BBA96-1220-4373-B993-5CD5CA151E62}</ProjectGuid>
  15 + <Keyword>Win32Proj</Keyword>
  16 + <RootNamespace>mdpwrapper</RootNamespace>
18 17 </PropertyGroup>
19 18 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
20 19 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
21 20 <ConfigurationType>DynamicLibrary</ConfigurationType>
22 21 <UseDebugLibraries>true</UseDebugLibraries>
23   - <CLRSupport>true</CLRSupport>
24 22 <CharacterSet>Unicode</CharacterSet>
25 23 </PropertyGroup>
26 24 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
27 25 <ConfigurationType>DynamicLibrary</ConfigurationType>
28 26 <UseDebugLibraries>false</UseDebugLibraries>
29   - <CLRSupport>true</CLRSupport>
  27 + <WholeProgramOptimization>true</WholeProgramOptimization>
30 28 <CharacterSet>Unicode</CharacterSet>
31 29 </PropertyGroup>
32 30 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -41,63 +39,71 @@
41 39 <PropertyGroup Label="UserMacros" />
42 40 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
43 41 <LinkIncremental>true</LinkIncremental>
44   - <IncludePath>..\..\..\libmdp\include;..\deps\czmq\include;..\deps\zeromq\include;$(IncludePath)</IncludePath>
  42 + <IncludePath>C:\Users\jam\code\zeromq3-x\include;C:\Users\jam\code\czmq\include;C:\Users\jam\code\majordomo\libmdp\include;$(IncludePath)</IncludePath>
  43 + <LibraryPath>C:\Users\jam\code\zeromq3-x\lib\Win32;C:\Users\jam\code\czmq\win32;C:\Users\jam\code\majordomo\builds\msvc\Release;C:\Users\jam\code\majordomo\builds\msvc\Debug;$(LibraryPath)</LibraryPath>
45 44 </PropertyGroup>
46 45 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
47 46 <LinkIncremental>false</LinkIncremental>
48   - <IncludePath>..\..\..\libmdp\include;..\deps\czmq\include;..\deps\zeromq\include;$(IncludePath)</IncludePath>
  47 + <IncludePath>$(IncludePath)</IncludePath>
  48 + <LibraryPath>$(LibraryPath)</LibraryPath>
49 49 </PropertyGroup>
50 50 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
51 51 <ClCompile>
  52 + <PrecompiledHeader>Use</PrecompiledHeader>
52 53 <WarningLevel>Level3</WarningLevel>
53 54 <Optimization>Disabled</Optimization>
54   - <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
55   - <PrecompiledHeader>Use</PrecompiledHeader>
  55 + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MDPWRAPPER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
56 56 </ClCompile>
57 57 <Link>
  58 + <SubSystem>Windows</SubSystem>
58 59 <GenerateDebugInformation>true</GenerateDebugInformation>
59   - <AdditionalDependencies>../deps/zeromq/lib/libzmq.lib;../deps/czmq/lib/czmq.lib;../deps/libmdp/lib/libmdp.lib;%(AdditionalDependencies)</AdditionalDependencies>
60   - <IgnoreSpecificDefaultLibraries>libcmtd.lib</IgnoreSpecificDefaultLibraries>
  60 + <AdditionalDependencies>Ws2_32.lib;Rpcrt4.lib;libzmq.lib;czmq.lib;libmdp.lib</AdditionalDependencies>
61 61 </Link>
62 62 </ItemDefinitionGroup>
63 63 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64 64 <ClCompile>
65 65 <WarningLevel>Level3</WarningLevel>
66   - <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
67 66 <PrecompiledHeader>Use</PrecompiledHeader>
  67 + <Optimization>MaxSpeed</Optimization>
  68 + <FunctionLevelLinking>true</FunctionLevelLinking>
  69 + <IntrinsicFunctions>true</IntrinsicFunctions>
  70 + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MDPWRAPPER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  71 + <AdditionalIncludeDirectories>$(SolutionDir)deps\zeromq\include;$(SolutionDir)deps\czmq\include;$(SolutionDir)\..\..\libmdp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
68 72 </ClCompile>
69 73 <Link>
  74 + <SubSystem>Windows</SubSystem>
70 75 <GenerateDebugInformation>true</GenerateDebugInformation>
71   - <AdditionalDependencies>../deps/zeromq/lib/libzmq.lib;../deps/czmq/lib/czmq.lib;../deps/libmdp/lib/libmdp.lib;%(AdditionalDependencies)</AdditionalDependencies>
72   - <IgnoreSpecificDefaultLibraries>libcmtd.lib</IgnoreSpecificDefaultLibraries>
  76 + <EnableCOMDATFolding>true</EnableCOMDATFolding>
  77 + <OptimizeReferences>true</OptimizeReferences>
  78 + <AdditionalDependencies>Ws2_32.lib;Rpcrt4.lib;$(SolutionDir)\deps\zeromq\lib\libzmq.lib;$(SolutionDir)\deps\czmq\lib\czmq.lib;$(SolutionDir)\deps\libmdp\lib\libmdp.lib</AdditionalDependencies>
73 79 </Link>
  80 + <PostBuildEvent>
  81 + <Command>copy $(SolutionDir)\deps\zeromq\bin\libzmq.dll $(SolutionDir)$(ConfigurationName)\.
  82 +copy $(SolutionDir)\deps\libmdp\bin\libmdp.dll $(SolutionDir)$(ConfigurationName)\.</Command>
  83 + </PostBuildEvent>
74 84 </ItemDefinitionGroup>
75 85 <ItemGroup>
76   - <Reference Include="System" />
77   - <Reference Include="System.Data" />
78   - <Reference Include="System.Xml" />
  86 + <None Include="ReadMe.txt" />
79 87 </ItemGroup>
80 88 <ItemGroup>
81   - <ClInclude Include="resource.h" />
82   - <ClInclude Include="Stdafx.h" />
83   - <ClInclude Include="zeromq.majordomo.h" />
  89 + <ClInclude Include="mdpwrapper.h" />
  90 + <ClInclude Include="stdafx.h" />
  91 + <ClInclude Include="targetver.h" />
84 92 </ItemGroup>
85 93 <ItemGroup>
86   - <ClCompile Include="AssemblyInfo.cpp" />
87   - <ClCompile Include="Stdafx.cpp">
  94 + <ClCompile Include="dllmain.cpp">
  95 + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
  96 + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
  97 + </PrecompiledHeader>
  98 + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
  99 + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
  100 + </PrecompiledHeader>
  101 + </ClCompile>
  102 + <ClCompile Include="mdpwrapper.cpp" />
  103 + <ClCompile Include="stdafx.cpp">
88 104 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
89 105 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
90 106 </ClCompile>
91   - <ClCompile Include="zeromq.majordomo.cpp">
92   - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
93   - </ClCompile>
94   - </ItemGroup>
95   - <ItemGroup>
96   - <None Include="app.ico" />
97   - <None Include="ReadMe.txt" />
98   - </ItemGroup>
99   - <ItemGroup>
100   - <ResourceCompile Include="app.rc" />
101 107 </ItemGroup>
102 108 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
103 109 <ImportGroup Label="ExtensionTargets">
26 ...zeromq.majordomo/zeromq.majordomo.vcxproj.filters → ...ings/dotnet/mdpwrapper/mdpwrapper.vcxproj.filters
@@ -15,36 +15,28 @@
15 15 </Filter>
16 16 </ItemGroup>
17 17 <ItemGroup>
18   - <ClInclude Include="zeromq.majordomo.h">
  18 + <None Include="ReadMe.txt" />
  19 + </ItemGroup>
  20 + <ItemGroup>
  21 + <ClInclude Include="stdafx.h">
19 22 <Filter>Header Files</Filter>
20 23 </ClInclude>
21   - <ClInclude Include="Stdafx.h">
  24 + <ClInclude Include="targetver.h">
22 25 <Filter>Header Files</Filter>
23 26 </ClInclude>
24   - <ClInclude Include="resource.h">
  27 + <ClInclude Include="mdpwrapper.h">
25 28 <Filter>Header Files</Filter>
26 29 </ClInclude>
27 30 </ItemGroup>
28 31 <ItemGroup>
29   - <ClCompile Include="zeromq.majordomo.cpp">
  32 + <ClCompile Include="stdafx.cpp">
30 33 <Filter>Source Files</Filter>
31 34 </ClCompile>
32   - <ClCompile Include="AssemblyInfo.cpp">
  35 + <ClCompile Include="mdpwrapper.cpp">
33 36 <Filter>Source Files</Filter>
34 37 </ClCompile>
35   - <ClCompile Include="Stdafx.cpp">
  38 + <ClCompile Include="dllmain.cpp">
36 39 <Filter>Source Files</Filter>
37 40 </ClCompile>
38 41 </ItemGroup>
39   - <ItemGroup>
40   - <None Include="ReadMe.txt" />
41   - <None Include="app.ico">
42   - <Filter>Resource Files</Filter>
43   - </None>
44   - </ItemGroup>
45   - <ItemGroup>
46   - <ResourceCompile Include="app.rc">
47   - <Filter>Resource Files</Filter>
48   - </ResourceCompile>
49   - </ItemGroup>
50 42 </Project>
5 bindings/dotnet/zeromq.majordomo/Stdafx.cpp → bindings/dotnet/mdpwrapper/stdafx.cpp
... ... @@ -1,5 +1,8 @@
1 1 // stdafx.cpp : source file that includes just the standard includes
2   -// zeromq.majordomo.pch will be the pre-compiled header
  2 +// mdpwrapper.pch will be the pre-compiled header
3 3 // stdafx.obj will contain the pre-compiled type information
4 4
5 5 #include "stdafx.h"
  6 +
  7 +// TODO: reference any additional headers you need in STDAFX.H
  8 +// and not in this file
16 bindings/dotnet/mdpwrapper/stdafx.h
... ... @@ -0,0 +1,16 @@
  1 +// stdafx.h : include file for standard system include files,
  2 +// or project specific include files that are used frequently, but
  3 +// are changed infrequently
  4 +//
  5 +
  6 +#pragma once
  7 +
  8 +#include "targetver.h"
  9 +
  10 +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
  11 +// Windows Header Files:
  12 +#include <windows.h>
  13 +
  14 +
  15 +
  16 +// TODO: reference additional headers your program requires here
8 bindings/dotnet/mdpwrapper/targetver.h
... ... @@ -0,0 +1,8 @@
  1 +#pragma once
  2 +
  3 +// Including SDKDDKVer.h defines the highest available Windows platform.
  4 +
  5 +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
  6 +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
  7 +
  8 +#include <SDKDDKVer.h>
122 bindings/dotnet/zeromq.majordomo.csharp/Client.cs
... ... @@ -0,0 +1,122 @@
  1 +using System;
  2 +using System.Collections.Generic;
  3 +using System.Linq;
  4 +using System.Text;
  5 +using System.Runtime.InteropServices;
  6 +
  7 +namespace zeromq.majordomo.csharp
  8 +{
  9 + public struct Wrapper
  10 + {
  11 + [DllImport("mdpwrapper.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="#3")]
  12 + static extern IntPtr _client_new(String broker, int verbose);
  13 + [DllImport("mdpwrapper.dll", CallingConvention=CallingConvention.Cdecl, EntryPoint="#1")]
  14 + static extern void _client_destroy(out IntPtr handle);
  15 + [DllImport("mdpwrapper.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, EntryPoint = "#6")]
  16 + static extern void _client_send_string(IntPtr handle, String service, String message );
  17 + [DllImport("mdpwrapper.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "#4")]
  18 + static extern void _client_recv(IntPtr handle, IntPtr service, IntPtr message );
  19 + [DllImport("mdpwrapper.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "#6")]
  20 + static extern void _client_set_timeout(IntPtr handle, int timeout);
  21 +
  22 + internal static void client_set_timeout(IntPtr handle, int timeout)
  23 + {
  24 + _client_set_timeout(handle, timeout);
  25 + }
  26 +
  27 + internal static IntPtr client_new(string broker, int p)
  28 + {
  29 + return _client_new( broker, p );
  30 + }
  31 +
  32 + internal static void client_destroy(IntPtr handle)
  33 + {
  34 + _client_destroy(out handle);
  35 + }
  36 +
  37 + internal static void client_send_string(IntPtr handle, string service, string message)
  38 + {
  39 + _client_send_string(handle, service, message);
  40 + }
  41 +
  42 + internal static void client_recv(IntPtr handle, ref string service, ref string message)
  43 + {
  44 + IntPtr ppservice = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
  45 + IntPtr ppmessage = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
  46 +
  47 + _client_recv(handle, ppservice, ppmessage);
  48 + IntPtr pmessage = (IntPtr)Marshal.PtrToStructure(ppmessage, typeof(IntPtr));
  49 + message = Marshal.PtrToStringAnsi(pmessage);
  50 + IntPtr pservice = (IntPtr)Marshal.PtrToStructure(ppservice, typeof(IntPtr));
  51 + if (pservice != IntPtr.Zero)
  52 + {
  53 + service = Marshal.PtrToStringAnsi(pservice);
  54 + }
  55 + Marshal.FreeHGlobal(ppservice);
  56 + Marshal.FreeHGlobal(ppmessage);
  57 +
  58 +
  59 + }
  60 +
  61 +
  62 + }
  63 +
  64 + public class Client : IDisposable
  65 + {
  66 + IntPtr handle;
  67 +
  68 + /*
  69 + * Instantiate client and connect to broker.
  70 + *
  71 + * ex. Client c = new Client( "tcp://192.168.1.7:5555", true );
  72 + */
  73 + public Client(String broker, bool verbose)
  74 + {
  75 + handle = Wrapper.client_new(broker, verbose ? 1 : 0);
  76 + }
  77 +
  78 + /*
  79 + * Send a message to worker identified by service argument
  80 + *
  81 + * ex. c.Send( "echo", "I like cheese" );
  82 + */
  83 + public void Send( String service, String message )
  84 + {
  85 + Wrapper.client_send_string( handle, service, message );
  86 + }
  87 +
  88 + /*
  89 + * Handles response (if any from worker) response may be null
  90 + */
  91 + public Response Recv()
  92 + {
  93 + Response response = null;
  94 + string service = string.Empty;
  95 + string message = string.Empty;
  96 + Wrapper.client_recv(handle, ref service, ref message);
  97 + if( !string.IsNullOrEmpty( message ) )
  98 + {
  99 + response = new Response(service, message);
  100 + }
  101 + return response;
  102 + }
  103 +
  104 + public int Timeout
  105 + {
  106 + set
  107 + {
  108 + Wrapper.client_set_timeout(handle, value);
  109 + }
  110 + }
  111 +
  112 +
  113 + /*
  114 + * Releases majordomo resources
  115 + */
  116 + public void Dispose()
  117 + {
  118 + Wrapper.client_destroy(handle);
  119 +
  120 + }
  121 + }
  122 +}
6 ...omo.test.workerconsole/Properties/AssemblyInfo.cs → ...eromq.majordomo.csharp/Properties/AssemblyInfo.cs
@@ -5,11 +5,11 @@
5 5 // General Information about an assembly is controlled through the following
6 6 // set of attributes. Change these attribute values to modify the information
7 7 // associated with an assembly.
8   -[assembly: AssemblyTitle("zeromq.majordomo.test.workerconsole")]
  8 +[assembly: AssemblyTitle("zeromq.majordomo.csharp")]
9 9 [assembly: AssemblyDescription("")]
10 10 [assembly: AssemblyConfiguration("")]
11 11 [assembly: AssemblyCompany("Hewlett-Packard Company")]
12   -[assembly: AssemblyProduct("zeromq.majordomo.test.workerconsole")]
  12 +[assembly: AssemblyProduct("zeromq.majordomo.csharp")]
13 13 [assembly: AssemblyCopyright("Copyright © Hewlett-Packard Company 2012")]
14 14 [assembly: AssemblyTrademark("")]
15 15 [assembly: AssemblyCulture("")]
@@ -20,7 +20,7 @@
20 20 [assembly: ComVisible(false)]
21 21
22 22 // The following GUID is for the ID of the typelib if this project is exposed to COM
23   -[assembly: Guid("0ea221df-7cb8-423f-9b8e-5eab0d213956")]
  23 +[assembly: Guid("7e0e3707-aaee-419f-8f28-a03f7ea665f2")]
24 24
25 25 // Version information for an assembly consists of the following four values:
26 26 //
44 bindings/dotnet/zeromq.majordomo.csharp/Response.cs
... ... @@ -0,0 +1,44 @@
  1 +using System;
  2 +using System.Collections.Generic;
  3 +using System.Linq;
  4 +using System.Text;
  5 +
  6 +namespace zeromq.majordomo.csharp
  7 +{
  8 + public class Response
  9 + {
  10 + private string service ;
  11 + private string message;
  12 +
  13 + internal Response( string service, string message )
  14 + {
  15 + this.service = service;
  16 + this.message = message;
  17 + }
  18 +
  19 + public string Service
  20 + {
  21 + get
  22 + {
  23 + return this.service;
  24 + }
  25 + }
  26 +
  27 + public string Message
  28 + {
  29 + get
  30 + {
  31 + return this.message;
  32 + }
  33 + }
  34 +
  35 + public void Print()
  36 + {
  37 + Console.WriteLine("Response");
  38 + Console.WriteLine(string.Format(" Service: {0}", this.service ));
  39 + Console.WriteLine(string.Format(" Message: {0}", this.message ));
  40 + }
  41 +
  42 +
  43 + }
  44 +}
30 ...onsole/zeromq.majordomo.test.workerconsole.csproj → ...q.majordomo.csharp/zeromq.majordomo.csharp.csproj
@@ -2,20 +2,18 @@
2 2 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 3 <PropertyGroup>
4 4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5   - <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
  5 + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6 6 <ProductVersion>8.0.30703</ProductVersion>
7 7 <SchemaVersion>2.0</SchemaVersion>
8   - <ProjectGuid>{2CF539D0-BE03-4B05-BF9E-72B27E4B4A92}</ProjectGuid>
9   - <OutputType>Exe</OutputType>
  8 + <ProjectGuid>{19176FD4-132B-4F17-B50C-2D9AD4D15435}</ProjectGuid>
  9 + <OutputType>Library</OutputType>
10 10 <AppDesignerFolder>Properties</AppDesignerFolder>
11   - <RootNamespace>zeromq.majordomo.test.workerconsole</RootNamespace>
12   - <AssemblyName>zeromq.majordomo.test.workerconsole</AssemblyName>
  11 + <RootNamespace>zeromq.majordomo.csharp</RootNamespace>
  12 + <AssemblyName>zeromq.majordomo.csharp</AssemblyName>
13 13 <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14   - <TargetFrameworkProfile>Client</TargetFrameworkProfile>
15 14 <FileAlignment>512</FileAlignment>
16 15 </PropertyGroup>
17   - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
18   - <PlatformTarget>x86</PlatformTarget>
  16 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19 17 <DebugSymbols>true</DebugSymbols>
20 18 <DebugType>full</DebugType>
21 19 <Optimize>false</Optimize>
@@ -24,8 +22,7 @@
24 22 <ErrorReport>prompt</ErrorReport>
25 23 <WarningLevel>4</WarningLevel>
26 24 </PropertyGroup>
27   - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
28   - <PlatformTarget>x86</PlatformTarget>
  25 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29 26 <DebugType>pdbonly</DebugType>
30 27 <Optimize>true</Optimize>
31 28 <OutputPath>bin\Release\</OutputPath>
@@ -43,19 +40,14 @@
43 40 <Reference Include="System.Xml" />
44 41 </ItemGroup>
45 42 <ItemGroup>
46   - <Compile Include="Program.cs" />
  43 + <Compile Include="Client.cs" />
47 44 <Compile Include="Properties\AssemblyInfo.cs" />
48   - </ItemGroup>
49   - <ItemGroup>
50   - <ProjectReference Include="..\zeromq.majordomo\zeromq.majordomo.vcxproj">
51   - <Project>{B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}</Project>
52   - <Name>zeromq.majordomo</Name>
53   - </ProjectReference>
  45 + <Compile Include="Response.cs" />
54 46 </ItemGroup>
55 47 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
56 48 <PropertyGroup>
57   - <PostBuildEvent>copy $(SolutionDir)\deps\libmdp\bin\libmdp.dll $(TargetDir).
58   -copy $(SolutionDir)\deps\zeromq\bin\libzmq.dll $(TargetDir).</PostBuildEvent>
  49 + <PostBuildEvent>
  50 + </PostBuildEvent>
59 51 </PropertyGroup>
60 52 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
61 53 Other similar extension points exist, see Microsoft.Common.targets.
25 bindings/dotnet/zeromq.majordomo.test.workerconsole/Program.cs
... ... @@ -1,25 +0,0 @@
1   -using System;
2   -using System.Collections.Generic;
3   -using System.Linq;
4   -using System.Text;
5   -
6   -
7   -namespace zeromq.majordomo.test.workerconsole
8   -{
9   - class Program
10   - {
11   - static void Main(string[] args)
12   - {
13   - Worker worker = new Worker("tcp://192.168.1.7:5555", "test", true);
14   - while (true)
15   - {
16   - string reply = "";
17   - string msg = worker.Recv(ref reply);
18   - Console.WriteLine( "Got " + msg + " reply to " + reply );
19   - worker.Send("pong", reply);
20   - }
21   -
22   -
23   - }
24   - }
25   -}
24 bindings/dotnet/zeromq.majordomo.testclient/Program.cs
@@ -2,23 +2,31 @@
2 2 using System.Collections.Generic;
3 3 using System.Linq;
4 4 using System.Text;
  5 +using zeromq.majordomo.csharp;
  6 +
5 7
6 8
7 9
8 10 namespace zeromq.majordomo.testclient
9 11 {
  12 +
  13 +
10 14 class Program
11 15 {
12 16 static void Main(string[] args)
13 17 {
14   - Client client = new Client("tcp:://192.168.1.7:5555", true );
15   - client.Timeout = 30;
16   - Console.WriteLine(client.BrokerBinding);
17   - client.Send("test", "ping");
18   - string service = "";
19   - string response = client.Recv(ref service);
20   - Console.WriteLine(response);
21   -
  18 + using (Client client = new Client("tcp://192.168.1.7:5555", true))
  19 + {
  20 + client.Send("echo", "hello");
  21 +
  22 + Response response = client.Recv();
  23 + if (response != null)
  24 + {
  25 + response.Print();
  26 + }
  27 +
  28 + }
  29 +
22 30 }
23 31 }
24 32 }
14 bindings/dotnet/zeromq.majordomo.testclient/zeromq.majordomo.test.clientconsole.csproj
@@ -33,6 +33,9 @@
33 33 <ErrorReport>prompt</ErrorReport>
34 34 <WarningLevel>4</WarningLevel>
35 35 </PropertyGroup>
  36 + <PropertyGroup>
  37 + <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
  38 + </PropertyGroup>
36 39 <ItemGroup>
37 40 <Reference Include="System" />
38 41 <Reference Include="System.Core" />
@@ -47,15 +50,16 @@
47 50 <Compile Include="Properties\AssemblyInfo.cs" />
48 51 </ItemGroup>
49 52 <ItemGroup>
50   - <ProjectReference Include="..\zeromq.majordomo\zeromq.majordomo.vcxproj">
51   - <Project>{B15631F1-BD9D-4B7C-8FC2-C07E8A7E451F}</Project>
52   - <Name>zeromq.majordomo</Name>
  53 + <ProjectReference Include="..\zeromq.majordomo.csharp\zeromq.majordomo.csharp.csproj">
  54 + <Project>{19176FD4-132B-4F17-B50C-2D9AD4D15435}</Project>
  55 + <Name>zeromq.majordomo.csharp</Name>
53 56 </ProjectReference>
54 57 </ItemGroup>
55 58 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
56 59 <PropertyGroup>
57   - <PostBuildEvent>copy $(SolutionDir)\deps\libmdp\bin\libmdp.dll $(TargetDir).
58   -copy $(SolutionDir)\deps\zeromq\bin\libzmq.dll $(TargetDir).
  60 + <PostBuildEvent>copy $(SolutionDir)$(ConfigurationName)\libmdp.dll $(TargetDir).
  61 +copy $(SolutionDir)$(ConfigurationName)\libzmq.dll $(TargetDir).
  62 +copy $(SolutionDir)$(ConfigurationName)\mdpwrapper.dll $(TargetDir).
59 63 </PostBuildEvent>
60 64 </PropertyGroup>
61 65 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
40 bindings/dotnet/zeromq.majordomo/AssemblyInfo.cpp
... ... @@ -1,40 +0,0 @@
1   -#include "stdafx.h"
2   -
3   -using namespace System;
4   -using namespace System::Reflection;
5   -using namespace System::Runtime::CompilerServices;
6   -using namespace System::Runtime::InteropServices;
7   -using namespace System::Security::Permissions;
8   -
9   -//
10   -// General Information about an assembly is controlled through the following
11   -// set of attributes. Change these attribute values to modify the information
12   -// associated with an assembly.
13   -//
14   -[assembly:AssemblyTitleAttribute("zeromqmajordomo")];
15   -[assembly:AssemblyDescriptionAttribute("")];
16   -[assembly:AssemblyConfigurationAttribute("")];
17   -[assembly:AssemblyCompanyAttribute("Hewlett-Packard Company")];
18   -[assembly:AssemblyProductAttribute("zeromqmajordomo")];
19   -[assembly:AssemblyCopyrightAttribute("Copyright (c) Hewlett-Packard Company 2012")];
20   -[assembly:AssemblyTrademarkAttribute("")];
21   -[assembly:AssemblyCultureAttribute("")];
22   -
23   -//
24   -// Version information for an assembly consists of the following four values:
25   -//
26   -// Major Version
27   -// Minor Version
28   -// Build Number
29   -// Revision
30   -//
31   -// You can specify all the value or you can default the Revision and Build Numbers
32   -// by using the '*' as shown below:
33   -
34   -[assembly:AssemblyVersionAttribute("1.0.*")];
35   -
36   -[assembly:ComVisible(false)];
37   -
38   -[assembly:CLSCompliantAttribute(true)];
39   -
40   -[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
7 bindings/dotnet/zeromq.majordomo/Stdafx.h
... ... @@ -1,7 +0,0 @@
1   -// stdafx.h : include file for standard system include files,
2   -// or project specific include files that are used frequently,
3   -// but are changed infrequently
4   -
5   -#pragma once
6   -
7   -
BIN  bindings/dotnet/zeromq.majordomo/app.ico
Binary file not shown
BIN  bindings/dotnet/zeromq.majordomo/app.rc
Binary file not shown
21 bindings/dotnet/zeromq.majordomo/mdp_wrapper.cpp
... ... @@ -1,21 +0,0 @@
1   -//#include "Stdafx.h"
2   -#include "mdp_wrapper.h"
3   -
4   -
5   -#include <mdp.h>
6   -//#include <set>
7   -
8   -using namespace zeromq::majordomo;
9   -
10   -//#pragma unmanaged
11   -
12   -
13   -
14   -void client_new( char* broker, int verbose ) {
15   -// mdp_client_t* p = mdp_client_new( broker, verbose );
16   -}
17   -
18   -//void client_destroy(void* ptr ) {
19   -
20   -// mdp_client_destroy( (mdp_client_t**)&ptr );
21   -//}
8 bindings/dotnet/zeromq.majordomo/mdp_wrapper.h
... ... @@ -1,8 +0,0 @@
1   -#pragma once
2   -
3   -namespace zeromq {
4   - namespace majordomo {
5   - void client_new( char* broker, int verbose );
6   - //void client_destroy(void* ptr );
7   - }
8   -}
3  bindings/dotnet/zeromq.majordomo/resource.h
... ... @@ -1,3 +0,0 @@
1   -//{{NO_DEPENDENCIES}}
2   -// Microsoft Visual C++ generated include file.
3   -// Used by app.rc
252 bindings/dotnet/zeromq.majordomo/zeromq.majordomo.cpp
... ... @@ -1,252 +0,0 @@
1   -// This is the main DLL file.
2   -
3   -#include "stdafx.h"
4   -//#include "mdp_wrapper.h"
5   -#include <mdp.h>
6   -
7   -#include "zeromq.majordomo.h"
8   -
9   -using namespace zeromq::majordomo;
10   -
11   -#pragma unmanaged
12   -void* client_new( char* broker, int verbose ) {
13   - mdp_client_t* handle = mdp_client_new( broker, verbose );
14   - return handle;
15   -}
16   -
17   -void client_destroy( void* handle_ptr ) {
18   - if( handle_ptr ) {
19   - mdp_client_t* handle = static_cast<mdp_client_t*>(handle_ptr);
20   - mdp_client_destroy( &handle );
21   - }
22   -}
23   -
24   -void client_set_timeout( void* handle_ptr, int timeout ) {
25   - assert( handle_ptr != NULL );
26   - assert( timeout >= 0 );
27   - mdp_client_t* handle = static_cast<mdp_client_t*>(handle_ptr);
28   - mdp_client_set_timeout( handle, timeout );
29   -
30   -}
31   -
32   -void client_send( void* handle_ptr, char* service, char* message ) {
33   - assert( handle_ptr != NULL );
34   - mdp_client_t* handle = static_cast<mdp_client_t*>(handle_ptr);
35   - zmsg_t *request = zmsg_new();
36   - zmsg_pushstr( request, message );
37   - mdp_client_send( handle, service, &request );
38   -}
39   -
40   -void extract_string_from_zmsg( zmsg_t* msg, char** contents ) {
41   - size_t message_size = zmsg_content_size( msg );
42   - *contents = static_cast<char*>(malloc(message_size + 1)); // extra byte for null
43   - char* p = *contents;
44   - while(true) {
45   - char* msg_part = zmsg_popstr( msg ) ;
46   - if( msg_part ) {
47   - strcpy( p, msg_part );
48   - p += strlen( msg_part ); // set pointer to empty part of the buffer
49   - free( msg_part );
50   - } else {
51   - break;
52   - }
53   - }
54   -}
55   -
56   -void client_recv( void* handle_ptr, char** message, char** service ) {
57   - assert( handle_ptr != NULL );
58   - mdp_client_t* handle = static_cast<mdp_client_t*>(handle_ptr);
59   - zmsg_t* response = mdp_client_recv( handle, service );
60   - if( response ) {
61   - extract_string_from_zmsg( response, message );
62   - zmsg_destroy( &response );
63   - }
64   -
65   -}
66   -
67   -///////////////////////////
68   -// Worker API
69   -//////////////////////////
70   -
71   -void* worker_new( char* broker, char* service, bool verbose ) {
72   - mdp_worker_t* handle = mdp_worker_new( broker, service, verbose );
73   - return handle;
74   -}
75   -
76   -void worker_destroy( void* handle_ptr ) {
77   - if( handle_ptr ) {
78   - mdp_worker_t* handle = static_cast<mdp_worker_t*>(handle_ptr);
79   - mdp_worker_destroy( &handle );
80   - }
81   -}
82   -
83   -void worker_set_heartbeat( void* handle_ptr, int heartbeat ) {
84   - assert( handle_ptr != NULL );
85   - mdp_worker_set_heartbeat( static_cast<mdp_worker_t*>(handle_ptr), heartbeat );
86   -}
87   -
88   -void worker_set_reconnect( void* handle_ptr, int reconnect ) {
89   - assert( handle_ptr != NULL );
90   - mdp_worker_set_reconnect( static_cast<mdp_worker_t*>(handle_ptr), reconnect );
91   -}
92   -
93   -void worker_recv( void* handle_ptr, char** message, char** reply_to ) {
94   - assert( handle_ptr != NULL );