Package org.eclipse.ecf.ipc

Examples of org.eclipse.ecf.ipc.IPCException


      }
      catch (IOException e)
      {
        String msg =
          "Error trying to read/write virtual file: " + getVirtualName();
        throw new IPCException(msg,e);
      }
    }
   
    setActualName(actual);
  }
View Full Code Here


   */
  public int write(byte[] buffer, int offset, int length, int timeoutMsec) throws IPCException
  {
    if (getDirection() != PipeDirection.Writer)
    {
      throw new IPCException("Attempt to write to a read-only pipe.");
    }

    FIFOResult result = new FIFOResult();
    writeImpl(result, buffer, offset, length, timeoutMsec);
    if (result.resultCode != FIFOResult.SUCCESS)
    {
      String msg = "Error writing named pipe, error code = " + result.errorCode;

      throw new IPCException(msg);
    }

    return result.byteCount;
  }
View Full Code Here

 
  public int read(byte[] buffer, int offset, int length, int timeoutMsec) throws IPCException
  {
    if (PipeDirection.Reader != getDirection())
    {
      throw new IPCException("Attempt to read a write-only pipe.");
    }

    FIFOResult result = new FIFOResult();
    readImpl(result, buffer, offset, length, timeoutMsec);

    if (result.resultCode == FIFOResult.ERROR_PIPE_CLOSED)
    {
      return -1;
    }
   
    if (result.resultCode != FIFOResult.SUCCESS)
    {
      String msg = "Error reading named pipe, code = " + result.errorCode;
      throw new IPCException(msg);
    }

    return result.byteCount;
  }
View Full Code Here

   */
  public void connect(File file, int size) throws IPCException
  {
    if (null != this.byteBuffer)
    {
      throw new IPCException(Errors.AlreadyConnected);
    }

    myFileCreator = false;
    try
    {
      myFileCreator = file.createNewFile();
    }
    catch (IOException e)
    {
      throw new IPCException(Errors.ExceptionCreatingFile, e);
    }

    RandomAccessFile raf = null;
    try
    {
      raf = new RandomAccessFile(file, "rw");
    }
    catch (FileNotFoundException e)
    {
      throw new IPCException(Errors.ErrorOpeningMappingFile, e);
    }

    channel = raf.getChannel();
    try
    {
      this.byteBuffer = channel.map(MapMode.READ_WRITE, 0, size);
    }
    catch (IOException e)
    {
      throw new IPCException(Errors.ErrorCreatingMap, e);
    }

    this.segmentFile = file;
    this.size = size;
  }
View Full Code Here

  {
    try
    {
      if (null == this.byteBuffer)
      {
        throw new IPCException(Errors.NotConnected);
      }

      this.byteBuffer.position(segmentOffset);
      this.byteBuffer.put(buf, buffOffset, bufLength);
    }
View Full Code Here

   */
  public int read(int soffset, byte[] buf, int boffset, int length) throws IPCException
  {
    if (null == byteBuffer)
    {
      throw new IPCException(Errors.NotConnected);
    }

    if (length > byteBuffer.remaining())
      length = byteBuffer.remaining();

View Full Code Here

        default:
          msg = "An unknown error was encountered while trying to create the named pipe";
          break;
      }

      throw new IPCException(msg);
    }
  }
View Full Code Here

    catch (IOException e)
    {
      String msg = "An error was encountered while trying to read the actual "
          + "name of a named pipe from its virtual name.";

      throw new IPCException(msg, e);
    }
  }
View Full Code Here

        case FIFOResult.ERROR_INVALID_HANDLE:
        {
          String msg = "Attempt to listen to an unconnected named pipe.  "
              + "Error code = " + result.errorCode;

          throw new IPCException(msg);
        }

        default:
        {
          String msg = "An unknown error was encountered while trying to listen "
              + "for a client.  " + "Error code = " + result.errorCode;

          throw new IPCException(msg);
        }
      }
    }
  }
View Full Code Here

    {
      case Success:
        break;

      case InsufficientPermissions:
        throw new IPCException(Errors.Permissions);

      default:
        throw new IPCException(Errors.Unknown);
    }

    setHandle(result.handle);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.ipc.IPCException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.