VitoPlantamura.com logo - Click here to go to the site home page... Click here to go to the site home page... Click here to go to the Blog page... Click here to go to the archives page... Click here to go to the about page...
"extremely impressive work"
- Mark Russinovich, www.sysinternals.com
(referring to my BugChecker)
my face...
Homepage of Vito Plantamura (@), Windows Researcher, VPC Technologies SRL CEO. [user=Guest] - updated: August 08, 2007
 NAMEDPIPE CLIENT/SERVER IPC CLASS
NAMEDPIPE CLIENT/SERVER IPC CLASS

INTRODUCTION

The CNamedPipeHost and CNamedPipeClient classes are two classes I have used in more than one project of mine in the past. They should be enough tested for being used with confidence in other projects as well. If you have suggestions and/or corrections about these implementations, please feel free to write to me.

They are intended expressly for client/server IPC purposes: in fact the server code waits and accepts only one connection from the corresponding peer. If you want to enable multiple CNamedPipeClients to connect to a single instance of a CNamedPipeHost, then you should modify opportunely the server implementation: the changes required in the CNamedPipeHost class in order to enable multiple client connections should be less than complex or extensive. As you may already know, named pipes created with the PIPE_TYPE_MESSAGE flag are message-based: this can be a very convenient solution over a corresponding TCP socket channel in the case when the nature of the protocol transported requires that the message boundaries have to be preserved.

TYPE DEFINITION DETAILS

class CNamedPipeHost
{
      // construction.
      CNamedPipeHost( charstring& strPipeName, PFNRECV pfnRecvCallback, int iRecvBufferSize, DWORD dwRecvCallbackParam, PFNCLOSE pfnCloseCallback = NULL );
 
      // methods.
      BOOL StartListening ();
      int Send ( CONST BYTE* pbBuffer, int nBufferSize );
      VOID DisconnectClient ();
};
 
class CNamedPipeClient
{
      // construction.
      CNamedPipeClient ( charstring& strPipeName, PFNRECV pfnRecvCallback, int iRecvBufferSize, DWORD dwRecvCallbackParam, PFNCLOSE pfnCloseCallback = NULL );
 
      // methods.
      BOOL Connect ();
      void Disconnect ( BOOL reserved = TRUE );
      VOID SetRecvCallbackParam( DWORD dwRecvCallbackParam );
      int Send ( CONST BYTE* pbBuffer, int nBufferSize );
 
      // properties.
      BOOL IsConnected ();
};

HOW TO USE

Simply instantiate the correct class (CNamedPipeHost when creating a named pipe server and CNamedPipeClient when creating a client) and then call the StartListening or the Connect method respectively.

REQUIRED DEFINITIONS

All my IPC classes use STL under the hood. Be sure to include the following definitions BEFORE the definitions of all my IPC types:

// Stl Stuff.
 
#include <string>
#include <vector>
#include <map>
typedef std::basic_string< CHAR > charstring;
typedef std::vector< charstring > charstring_vector;
typedef std::basic_string< WCHAR > widestring;
typedef std::vector< widestring > widestring_vector;

ACTUAL CODE

NamePipe_code.h

 Quotes
"Among the Windows experts I know personally, no one can beat Vito Plantamura."
- Francesco Balena, Code Architects SRL

"Your NDIS Monitor application, is amongst the most impressive networking code I have seen on the .Net framework."
- Ben Hakim.
 Photos
Various images from italian conferences and events (keep the mouse on a thumbnail for a short description):
Me at the Microsoft/HP/Intel organized Route64 event in Milan in May 2005, explaining how COM+ behaves on 64-bit Microsoft operating systems. I was there with the friends of Code Architects.
Me at the Microsoft Security Roadshow event in Bari in April 2006, explaining how the logon process works in Windows NT. There were 250 attendees.
Microsoft Security Roadshow 2006 in Treviso. This is an image of the huge 700-seats conference room.
Me at the Microsoft Security Roadshow 2006 in Treviso. This is a moment of the 3-hours session.
 Site login
NOTE: Actually the login feature is used only for administrative and content management purposes.
Username

Password

Everything here (code, binaries, text, graphics, design, html) is © 2010 Vito Plantamura and VPC Technologies SRL (VATID: IT06203700965).
If you download something (compilable or not) from the site, you should read the license policy file.
If you want to contact me via email, write at this address.