Home | History | Annotate | Download | only in net
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package androidx.core.net;
     18 
     19 import java.io.FileDescriptor;
     20 import java.io.IOException;
     21 import java.io.InputStream;
     22 import java.io.OutputStream;
     23 import java.net.DatagramSocket;
     24 import java.net.InetAddress;
     25 import java.net.Socket;
     26 import java.net.SocketAddress;
     27 import java.net.SocketException;
     28 import java.net.SocketImpl;
     29 
     30 class DatagramSocketWrapper extends Socket {
     31     DatagramSocketWrapper(DatagramSocket socket, FileDescriptor fd) throws SocketException {
     32         super(new DatagramSocketImplWrapper(socket, fd));
     33     }
     34 
     35     /**
     36      * Empty implementation which wires in the given {@link FileDescriptor}.
     37      */
     38     private static class DatagramSocketImplWrapper extends SocketImpl {
     39         DatagramSocketImplWrapper(DatagramSocket socket, FileDescriptor fd) {
     40             super();
     41             this.localport = socket.getLocalPort();
     42             this.fd = fd;
     43         }
     44 
     45         @Override
     46         protected void accept(SocketImpl newSocket) throws IOException {
     47             throw new UnsupportedOperationException();
     48         }
     49 
     50         @Override
     51         protected int available() throws IOException {
     52             throw new UnsupportedOperationException();
     53         }
     54 
     55         @Override
     56         protected void bind(InetAddress address, int port) throws IOException {
     57             throw new UnsupportedOperationException();
     58         }
     59 
     60         @Override
     61         protected void close() throws IOException {
     62             throw new UnsupportedOperationException();
     63         }
     64 
     65         @Override
     66         protected void connect(String host, int port) throws IOException {
     67             throw new UnsupportedOperationException();
     68         }
     69 
     70         @Override
     71         protected void connect(InetAddress address, int port) throws IOException {
     72             throw new UnsupportedOperationException();
     73         }
     74 
     75         @Override
     76         protected void create(boolean isStreaming) throws IOException {
     77             throw new UnsupportedOperationException();
     78         }
     79 
     80         @Override
     81         protected InputStream getInputStream() throws IOException {
     82             throw new UnsupportedOperationException();
     83         }
     84 
     85         @Override
     86         protected OutputStream getOutputStream() throws IOException {
     87             throw new UnsupportedOperationException();
     88         }
     89 
     90         @Override
     91         protected void listen(int backlog) throws IOException {
     92             throw new UnsupportedOperationException();
     93         }
     94 
     95         @Override
     96         protected void connect(SocketAddress remoteAddr, int timeout) throws IOException {
     97             throw new UnsupportedOperationException();
     98         }
     99 
    100         @Override
    101         protected void sendUrgentData(int value) throws IOException {
    102             throw new UnsupportedOperationException();
    103         }
    104 
    105         @Override
    106         public Object getOption(int optID) throws SocketException {
    107             throw new UnsupportedOperationException();
    108         }
    109 
    110         @Override
    111         public void setOption(int optID, Object val) throws SocketException {
    112             throw new UnsupportedOperationException();
    113         }
    114     }
    115 }
    116