All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jcifs.smb.SmbNamedPipe Maven / Gradle / Ivy

There is a newer version: 2.1.10
Show newest version
/* jcifs smb client library in Java
 * Copyright (C) 2000  "Michael B. Allen" 
 *                     "Paul Walker" 
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package jcifs.smb;


import java.net.MalformedURLException;

import jcifs.CIFSContext;
import jcifs.SmbPipeHandle;
import jcifs.SmbPipeResource;
import jcifs.internal.smb1.com.SmbComNTCreateAndX;
import jcifs.internal.smb1.com.SmbComNTCreateAndXResponse;


/**
 * This class will allow a Java program to read and write data to Named
 * Pipes and Transact NamedPipes.
 *
 * 

* There are three Win32 function calls provided by the Windows SDK * that are important in the context of using jCIFS. They are: * *

    *
  • CallNamedPipe A message-type pipe call that opens, * writes to, reads from, and closes the pipe in a single operation. *
  • TransactNamedPipe A message-type pipe call that * writes to and reads from an existing pipe descriptor in one operation. *
  • CreateFile, ReadFile, * WriteFile, and CloseFile A byte-type pipe can * be opened, written to, read from and closed using the standard Win32 * file operations. *
* *

* The jCIFS API maps all of these operations into the standard Java * XxxputStream interface. A special PIPE_TYPE * flags is necessary to distinguish which type of Named Pipe behavior * is desired. * *

*

* * * * * * * * * * * * * * * * * * *
SmbNamedPipe Constructor Examples
Code SampleDescription
* *
 * new SmbNamedPipe("smb://server/IPC$/PIPE/foo", SmbNamedPipe.PIPE_TYPE_RDWR | SmbNamedPipe.PIPE_TYPE_CALL, context);
 * 
* *
* Open the Named Pipe foo for reading and writing. The pipe will behave like the CallNamedPipe interface. *
* *
 * new SmbNamedPipe("smb://server/IPC$/foo", SmbNamedPipe.PIPE_TYPE_RDWR | SmbNamedPipe.PIPE_TYPE_TRANSACT, context);
 * 
* *
* Open the Named Pipe foo for reading and writing. The pipe will behave like the TransactNamedPipe * interface. *
* *
 * new SmbNamedPipe("smb://server/IPC$/foo", SmbNamedPipe.PIPE_TYPE_RDWR, context);
 * 
* *
* Open the Named Pipe foo for reading and writing. The pipe will * behave as though the CreateFile, ReadFile, * WriteFile, and CloseFile interface was * being used. *
* *

* See Using jCIFS to Connect to Win32 * Named Pipes for a detailed description of how to use jCIFS with * Win32 Named Pipe server processes. * */ public class SmbNamedPipe extends SmbFile implements SmbPipeResource { private final int pipeType; /** * Open the Named Pipe resource specified by the url * parameter. The pipeType parameter should be at least one of * the PIPE_TYPE flags combined with the bitwise OR * operator |. See the examples listed above. * * @param url * @param pipeType * @param unshared * whether to use an exclusive connection for this pipe * @param tc * @throws MalformedURLException */ public SmbNamedPipe ( String url, int pipeType, boolean unshared, CIFSContext tc ) throws MalformedURLException { super(url, tc); this.pipeType = pipeType; setNonPooled(unshared); if ( !getLocator().isIPC() ) { throw new MalformedURLException("Named pipes are only valid on IPC$"); } this.fileLocator.updateType(TYPE_NAMED_PIPE); } /** * Open the Named Pipe resource specified by the url * parameter. The pipeType parameter should be at least one of * the PIPE_TYPE flags combined with the bitwise OR * operator |. See the examples listed above. * * @param url * @param pipeType * @param tc * @throws MalformedURLException */ public SmbNamedPipe ( String url, int pipeType, CIFSContext tc ) throws MalformedURLException { this(url, pipeType, ( pipeType & SmbPipeResource.PIPE_TYPE_UNSHARED ) != 0, tc); } /** * {@inheritDoc} * * @see jcifs.smb.SmbFile#customizeCreate(jcifs.internal.smb1.com.SmbComNTCreateAndX, * jcifs.internal.smb1.com.SmbComNTCreateAndXResponse) */ @Override protected void customizeCreate ( SmbComNTCreateAndX request, SmbComNTCreateAndXResponse response ) { request.addFlags0(0x16); response.setExtended(true); } /** * {@inheritDoc} * * @see jcifs.smb.SmbFile#getType() */ @Override public int getType () throws SmbException { return TYPE_NAMED_PIPE; } /** * @return the pipe type */ @Override public int getPipeType () { return this.pipeType; } /** * @return a handle for interacting with the pipe */ @Override public SmbPipeHandle openPipe () { return new SmbPipeHandleImpl(this); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy