Package java.net

Examples of java.net.SocketException


    /**
     * @see java.net.SocketOptions#getOption(int)
     */
    public final synchronized Object getOption(int option_id) throws SocketException {
        if (closed) {
            throw new SocketException("DatagramSocket closed");
        }
        switch (option_id) {
            case IP_TOS:
                return tos;
            case SO_BINDADDR:
View Full Code Here


                return doGetOption(option_id);
        }
    }

    protected Object doGetOption(int option_id) throws SocketException {
        throw new SocketException("Unknown option " + option_id);
    }
View Full Code Here

    /**
     * @see java.net.SocketOptions#setOption(int, java.lang.Object)
     */
    public final synchronized void setOption(int option_id, Object val) throws SocketException {
        if (closed) {
            throw new SocketException("DatagramSocket closed");
        }
        try {
            switch (option_id) {
                case IP_TOS:
                    tos = (Integer) val;
                    break;
                case SO_BINDADDR:
                    throw new SocketException("Get only option: SO_BINDADDR");
                case SO_BROADCAST:
                    broadcast = (Boolean) val;
                    break;
                case SO_RCVBUF: /* ignore */
                    break;
                case SO_SNDBUF: /* ignore */
                    break;
                case SO_TRANSMIT_IF:
                    if (val == null) {
                        device = null;
                    } else {
                        final NetworkInterface netIf = (NetworkInterface) val;
                        try {
                            device = DeviceUtils.getDevice(netIf.getName());
                        } catch (DeviceNotFoundException ex) {
                            throw new SocketException("Unknown networkinterface " + netIf.getName());
                        }
                    }
                    break;
                case SO_TIMEOUT:
                    timeout = (Integer) val;
                    break;
                case SO_REUSEADDR:
                    // Ignored for now
                    break;
                default:
                    doSetOption(option_id, val);
            }
        } catch (ClassCastException ex) {
            throw (SocketException) new SocketException("Invalid option type").initCause(ex);
        }
    }
View Full Code Here

    /**
     * @see java.net.DatagramSocketImpl#receive(java.net.DatagramPacket)
     */
    protected final void receive(DatagramPacket p) throws IOException {
        if (closed) {
            throw new SocketException("DatagramSocket has been closed");
        }
        final SocketBuffer skbuf = (SocketBuffer) receiveQueue.get(timeout);
        if (skbuf == null) {
            if (closed) {
                throw new SocketException("DatagramSocket has been closed");
            } else {
                throw new SocketTimeoutException("Timeout in receive");
            }
        } else {
            onReceive(p, skbuf);
View Full Code Here

     * Gets the SocketImplFactory of this protocol.
     *
     * @throws SocketException If this protocol is not Socket based.
     */
    public SocketImplFactory getSocketImplFactory() throws SocketException {
        throw new SocketException("UDP is packet based");
    }
View Full Code Here

     */
    protected synchronized void bind(UDPDatagramSocketImpl socket) throws SocketException {
        Integer lport = socket.getLocalPort();

        if (lport.compareTo(zero) != 0 && sockets.containsKey(lport)) {
            throw new SocketException("Port already bound (" + lport + ')');
        } else {
            Integer ran;

            while (lport.compareTo(zero) == 0) {
                ran = random.nextInt(stopRandom) + startRandom;
View Full Code Here

     * Gets the SocketImplFactory of this protocol.
     *
     * @throws SocketException If this protocol is not Socket based.
     */
    public SocketImplFactory getSocketImplFactory() throws SocketException {
        throw new SocketException("RAW is packet based");
    }
View Full Code Here

     * Gets the DatagramSocketImplFactory of this protocol.
     *
     * @throws SocketException If this protocol is not DatagramSocket based.
     */
    public DatagramSocketImplFactory getDatagramSocketImplFactory() throws SocketException {
        throw new SocketException("Not implemented yet");
    }
View Full Code Here

     * Gets the SocketImplFactory of this protocol.
     *
     * @throws SocketException If this protocol is not Socket based.
     */
    public SocketImplFactory getSocketImplFactory() throws SocketException {
        throw new SocketException("ICMP is packet based");
    }
View Full Code Here

     * Gets the DatagramSocketImplFactory of this protocol.
     *
     * @throws SocketException If this protocol is not DatagramSocket based.
     */
    public DatagramSocketImplFactory getDatagramSocketImplFactory() throws SocketException {
        throw new SocketException("Not implemented yet");
    }
View Full Code Here

TOP

Related Classes of java.net.SocketException

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.