[jcifs] Problem reading from named pipe

Michael B Allen mballen at erols.com
Thu Feb 14 07:13:51 EST 2002


On Wed, 13 Feb 2002 10:42:49 -0800
Sean Ryan <sryan at clear-tec.com> wrote:

> I am getting this exception when attempting to read from a named pipe :
>  
> jcifs.smb.SmbException: No description available. Please update error string
> for errorCode=233

Error code 233 is

  No process is on the other end of the pipe.

I guess I should add that one to the list of error strings. You can
resolve an error code with:

  C:\> net helpmsg 233

on a Windows machine.

> The code is as follows:
>  
>  try {
>   SmbNamedPipe pipe =
>    new SmbNamedPipe(
>     "smb://ryan:madeup@hammerhead/IPC$/tran.dat",
>     SmbNamedPipe.PIPE_TYPE_RDWR);
>  
>   InputStream is = pipe.getNamedPipeInputStream();
>   OutputStream os = pipe.getNamedPipeOutputStream();
>   InputStreamReader isr = new InputStreamReader(is);
>   OutputStreamWriter osw = new OutputStreamWriter(os);
>   BufferedWriter bw = new BufferedWriter(osw);
>   LineNumberReader lnr = new LineNumberReader(isr);
>   PrintWriter pw = new PrintWriter(bw, true);
>  
>   for (int i = 0; i < 10; i++) {
>    pw.println(TRAN_RECORD);
> //   Thread.sleep(1000);
>    String s = lnr.readLine();
>    System.out.println(s);
>   }
>  
>  } catch (Exception e) {
>   e.printStackTrace();
>  }

Ok, I guess that's fine. But it's odd that you named the pipe tran.dat. It
looks like a file. Anyways, how did you create the pipe in your Win32
pipe process? I think you want something like:

   h = CreateNamedPipe("\\\\.\\PIPE\\tran.dat",
		PIPE_ACCESS_DUPLEX,
		PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
		nMaxInstances,
		nOutBufferSize, nInBufferSize,
		NMPWAIT_WAIT_FOREVER, NULL);

Is that what you're doing? Also, don't rule out using transact named
pipe style. From the "tran" word in your code it sounds like you want
to issue a "transaction". Meaning you send a command and get a response?

> The first iteration works, but on the second iteration the exception is
> thrown.

Ah, well it sounds like your pipe process exited. You need a loop!

>  If I put the "sleep" for 1 second in, I don't get the exception.  I

Oh, ok, maybe not. Then something is instructing the pipe process to
close and restart? Is it in a loop? What does your Win32 pipe code look
like? Are you using max instances equals 1 maybe?

> have narrowed it down to this part of the SmbTransport.send method :
>  
>  switch (response.errorCode & 0xFF) {
>   case SmbException.SUCCESS :
>    break;
>   case SmbException.ERRDOS :
>    switch ((response.errorCode >> 16) & 0xFFFF) {
>     case SmbException.ERRnoaccess :
>      throw new SmbAuthException(response.errorCode);
>    }
>    throw new SmbException(response.errorCode);
> <<<<<<<<<<<<<<<----------------

Ok, well this is just reporting the error code returned by the server.

>   case SmbException.ERRSRV :
>    switch ((response.errorCode >> 16) & 0xFFFF) {
>     case SmbException.ERRbadpw :
>     case SmbException.ERRaccess :
>     case SmbException.ERRaccountExpired :
>  
> The value of response just before the exception is thrown is :
>  
> SmbComReadAndXResponse[command=SMB_COM_READ_ANDX,received=true,errorCode=No
> description available. Please update error string for
> errorCode=233,flags=0x0098,flags2=0x8001,tid=2048,pid=19719,uid=2048,mid=7,w
> ordCount=0,byteCount=0,andxCommand=0xFF,andxOffset=0,dataCompactionMode=0,da
> taLength=0,dataOffset=0]
>  
> The value of request just before the exception is thrown is :
>  
> SmbComReadAndX[command=SMB_COM_READ_ANDX,received=false,errorCode=0x00000000
> ,flags=0x0018,flags2=0x8001,tid=2048,pid=19719,uid=2048,mid=7,wordCount=12,b
> yteCount=0,andxCommand=0xFF,andxOffset=0,fid=2048,offset=72,maxCount=4096,mi
> nCount=4096,openTimeout=-1,remaining=0,offset=4096]

Mmm, I don't see anything obviously wrong here.

> I am running within IBM VisualAge for Java 3.5 on Windows NT Workstation
> 4.0, and the process on the other end of the named pipe is a native NT
> application running on locally on my machine.

Ok, sounds good. I guess I really need to reproduce the Win32 code. Can
you modify the examples/pipes/createnp.c example to simulate the
problem? Perhaps you could just show me the important snipplet of that
code. I'm not sure what's going on.

Also, you know about this page right?

  http://jcifs.samba.org/src/docs/pipes.html

Mike

-- 
May The Source be with you.




More information about the jcifs mailing list