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,
(referring to my BugChecker)
my face...
Homepage of Vito Plantamura (@, LinkedIn), Windows Researcher and Developer. [user=Guest] - updated: August 08, 2007


The CWinSockStreamSendRecv class is a class I have used in more than one project of mine in the past. It should be enough tested for being used with confidence in other projects as well. If you have suggestions and/or corrections about this implementation, please feel free to write to me.

It is 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 write massive server-oriented WinSock applications, consider the use of I/O Completion Ports under Windows NT instead of a raw socket implementation. As you may already know connection-oriented TCP sockets are stream-oriented: if you need a message-based IPC mechanism, take a look at my named pipe classes.

Additionally you should consider controlling the access to its blocking "Send" method with a critical section (for example) if you plan to consume this object from multiple threads simultaneously.


class CWinSockStreamSendRecv
      // construction.
      CWinSockStreamSendRecv( charstring& strHost, unsigned short usPort, PFNRECV pfnRecvCallback, int iRecvBufferSize, DWORD dwRecvCallbackParam, PFNCLOSE pfnCloseCallback = NULL );
      // methods.
      BOOL Connect ();
      void Disconnect ( BOOL wait = TRUE );
      int Send ( CONST BYTE* pbBuffer, int nBufferSize );
      // properties.
      VOID SetFilterAddress( in_addr address );
      VOID SetPort( unsigned short port );
      BOOL IsConnected ();


Simply instantiate the class and then call the Connect method. Constructing the instance specifying or not the "strHost" parameter determines whether the resulting object will represent a server or a client socket: if you specify the host name, the object will be the client part, conversely if you omit it, the resulting object will be the server part listening and accepting connections.


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;



"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.
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.


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.