Package org.jtestserver.common.protocol

Examples of org.jtestserver.common.protocol.ProtocolException


        try {
            LOGGER.log(Level.INFO, "xml report: " + report);
           
            return parser.parse(sr);
        } catch (XMLParseException e) {
            throw new ProtocolException("invalid XML answer", e);
        } catch (IOException e) {
            throw new ProtocolException("I/O error", e);
        }
    }
View Full Code Here


   
    public void setTimeout(int timeout) throws ProtocolException {
        try {
            socket.setSoTimeout(timeout);
        } catch (SocketException se) {
            throw new ProtocolException(se);
        }
    }
View Full Code Here

   
    public void setTimeout(int timeout) throws ProtocolException {
        try {
            socket.setSoTimeout(timeout);
        } catch (SocketException se) {
            throw new ProtocolException(se);
        }
    }
View Full Code Here

        socket.close();
    }
   
    protected void ensureConnected() throws ProtocolException {
        if (socket.isClosed()) {
            throw new ProtocolException("connection is closed");
        }
       
        if (!socket.isConnected()) {
            socket.connect(serverIp, serverPort);
        }
View Full Code Here

    @Override
    public final UDPClient createClient(InetAddress serverIp, int serverPort) throws ProtocolException {
        try {
            return new UDPClient(this, serverIp, serverPort);
        } catch (SocketException e) {
            throw new ProtocolException(e);
        }
    }
View Full Code Here

    @Override
    public final UDPServer createServer(int localPort) throws ProtocolException {
        try {
            return new UDPServer(this, localPort);
        } catch (SocketException e) {
            throw new ProtocolException(e);
        }
    }
View Full Code Here

//            bb.putInt(command.length()).asCharBuffer().append(command);
//            socket.getChannel().send(bb, socket.getRemoteSocketAddress());
        } catch (SocketTimeoutException e) {
            throw new TimeoutException("timeout in receive", e);
        } catch (IOException e) {
            throw new ProtocolException("error in receive", e);
        }
    }
View Full Code Here

            socket.receive(packet);
            int size = ByteBuffer.wrap(data).getInt();

            LOGGER.log(Level.INFO, "nb bytes received : " + size);
            if (size > MAX_SIZE) {
                throw new ProtocolException(
                        "stream probably corrupted : received more than "
                        + MAX_SIZE + " bytes (" + size + ")");
            }
           
            // receive actual data
            data = new byte[size];
            packet = new DatagramPacket(data, data.length);
            socket.receive(packet);
           
            return new ReceivedMessage(new String(packet.getData()), packet.getSocketAddress());
           
//            ByteBuffer bb = ByteBuffer.allocate(INT_SIZE);
//            socket.getChannel().read(bb);
//            int size = bb.getInt();
//            bb = ByteBuffer.allocate(size);
//            socket.getChannel().read(bb);
//           
//            return bb.asCharBuffer().rewind().toString();
        } catch (SocketTimeoutException e) {
            throw new TimeoutException("timeout in receive", e);
        } catch (IOException e) {
            throw new ProtocolException("error in receive", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.jtestserver.common.protocol.ProtocolException

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.