Thursday, January 10, 2008

Asynchronous Named Pipes (Overlapped IO) with VB.NET

Asynchronous Named Pipes (Overlapped IO) with VB.NET (CodeProject)
An article on creating a library that takes advantage of the native Win32 overlapped IO for asynchronous named pipe communication.
Download demo application binaries - 20.5 Kb
Download demo application source code - 35.4 Kb
Download NamedPipes library binary - 9.96 Kb
Download demo application - 24.8 Kb


This article shows the fine points of taking advantage of the Windows Overlapped API for asynchronous communication through named pipes. The greatest achievement of this code compared to other similar ones is that the server and client actually stop when you tell them to.

PipeListenner

Dim WithEvents Listenner As New _
NamedPipes.PipeListener("myPipe")
Listenner.StartListenning

Private Sub Listenner_ClientConnected(ByVal sender As Object, _
ByVal e As NamedPipes.ClientConnectedEventArgs) _
Handles P.ClientConnected
e.ClientStream.Read
e.CleintStream.Write
...
End Sub


PipeClient

Dim Client As New NamedPipes.PipeClient("\\.\pipe\myPipe")
Client.Connect
Client.ClientStream.Read
Client.ClientStream.Write
...

No comments: