[jcifs] jCifs writing to Mailslots

Sascha Teifke sascha at teifke.de
Tue Jun 10 00:42:11 EST 2003

Hello list,

I'm new in Java and I want to write a java prog. to send
Data to a Mailslot, specially the Mailslot who brings the
net send Messages up.

I did it once in Perl and it worked fine. Now I try to make it
in Java because I expect a better performance.

In Perl I used the Win32::Pipe Module which allowes it to send
Data to a Windows Named Pipe.

== Perl stuff ==
my $Pipe = new Win32::Pipe ("\\\\$Host\\mailslot\\messngr");
my $Message = "Sender\0$Host\0This is a Test \0\0";
my $Result = $Pipe->Write ( $Message );
== End of Perl stuff ==

This worked out fine ...

But now:
I used the CallNamedPipe example and tried to modify it to meet my needs.

== Java prog ==
import jcifs.smb.SmbNamedPipe;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class HelloJava {
	public static void main ( String[] args ) throws Exception {
         byte[] b = new byte[128];
	int n = 4;

	FileOutputStream fos = new FileOutputStream( "SENDER\0SENDER\0My 
Message \0\0" );

         SmbNamedPipe pipe = new SmbNamedPipe( 
                 SmbNamedPipe.PIPE_TYPE_WRONLY | 
SmbNamedPipe.PIPE_TYPE_CALL );
         OutputStream out = pipe.getNamedPipeOutputStream();

         fos.write(b, 0, n );

== End of Java Prog ==

I am using Ethereal for sniffing the packets round my LAN. While running 
the prog there were exeptions thrown an no packets were send.

Browsing through the jCifs docs didn't show me the right way so any help 
would be appreciated.

Thank you in advance


More information about the jcifs mailing list