Package agentj.nativeimp.util

Examples of agentj.nativeimp.util.DataPacket


        } finally {
            // don't need
           // impl.releaseFD();
        }

        sp = new DataPacket(inputBuffer, off, n);
        cont.executeCallback(this);
    }
View Full Code Here


        } else {
            logger.trace("No Data left, need to wait for data ...");
          offForRead=off;
          lengthForRead=length;

          DataPacket sp;
       
          // IAN: enable asynchronous callback for data - only read when ready 8:)
          sp = (DataPacket)waitForDataEvent();
       
          logger.debug("Socket ID = " + _socketid + ", Sync unlocked, reading data now ... ");

          if (isLocalDataConnection()) {
            logger.debug("SocketInputStream read: retrieving local data now... Socket ID = " + _socketid);

            System.arraycopy(localData,off,b,0,localData.length); // clean up data

            return localData.length;
          }
          logger.debug("SocketInputStream read: Got remote data, parsing now.... ");

          n = sp.getLength();

          byte buf[] = new byte[b.length];
          // acquire file descriptor and do the read

            logger.debug("SocketInputStream read: copying to read buffer.... ");

          System.arraycopy(sp.getData(),0,b,off,sp.getLength()); // copy data

            logger.debug("SocketInputStream read: copied ok.... ");

            /*
             * We receive a "connection reset" but there may be bytes still
             * buffered on the socket
             */
             if (gotReset) {
                 impl.setConnectionResetPending();
                 System.arraycopy(sp.getData(),0,b,off,sp.getLength()); // copy data
                 if (n > 0) {
                     return n;
                 }
             }
       }
View Full Code Here

                if (fd != null && fd1 != null ) {
                    /* must be unbound or else bound to anyLocal */
                    return anyLocalBoundAddr;
                }
                //   InetAddressContainer in = new InetAddressContainer();
                DataPacket dp = new DataPacket();
                ret = socketGetOptionJava(opt,dp ); // need to fix
                return AgentJNameService.getIPAddress(dp.getAddress());
            case SO_SNDBUF:
            case SO_RCVBUF:
                ret = socketGetOptionJava(opt, null);
                return new Integer(ret);
            case IP_TOS:
View Full Code Here

        return sync;
    }


    private void readRemote(DatagramPacket intoPacket) throws IOException {
        DataPacket data=makeDatapacket(intoPacket);

        AgentJAgent.getLock().lock()// block until condition holds
        try {
            receive0(data);
        } finally {
View Full Code Here

        logger.debug("Send: About to lock for send now");

        AgentJAgent.getLock().lock()// block until condition holds

        try {
            DataPacket data=makeDatapacket(p);
            logger.debug("Native Java UPD IMplementation: Sending data now");
            send0(data);
            refillDataPacket(data, p);
        } finally {
            AgentJAgent.getLock().unlock();
View Full Code Here

    }

    // to go in.

    private DataPacket makeDatapacket(DatagramPacket p) throws IOException {
        DataPacket data = new DataPacket(p.getData(),p.getOffset(),p.getLength());
        if (p.getAddress()!=null) {
            data.setAddress(AgentJNameService.getNSAddress(p.getAddress().getHostName()));
            data.setPort(p.getPort());
        }
        return data;
    }
View Full Code Here

        AgentJAgent.getLock().lock()// block until condition holds

        int bytes=0;

        try {
            DataPacket data=makeDatapacket(p);
            peekData(data);
            refillDataPacket(data, p);
            bytes=data.getData()[0];
        } finally {
            AgentJAgent.getLock().unlock();
        }

        return bytes;
View Full Code Here

     * @see agentj.thread.AgentJEventQueue
     * @param payload
     * @throws IOException
     */
    public void doSend(Object payload) throws IOException {
        DataPacket data = (DataPacket)payload;
        sendEnabled =true;
        socketWrite(data.getData(), data.getOffset(), data.getLength());
        sendEnabled =false;
    }
View Full Code Here

        logger.debug("Sending Data from : " + impl.getSocketLogInfo()
                        + ", Port " + impl.getMyLocalPort()
                + " to DAddr " +  impl.getDstAddress() + ", DPort " + impl.getDstPort());

        if ((!sendEnabled) && (isLocalDataConnection())) { // if not sending pop this send on the queue
            AgentJEventQueue.pushEvent(this, new DataPacket(b,off,len));
            return;
        }

        if (len <= 0 || off < 0 || off + len > b.length) {
            if (len == 0) {
View Full Code Here

TOP

Related Classes of agentj.nativeimp.util.DataPacket

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.