01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.luni.net;
19:
20: import java.io.FileDescriptor;
21: import java.io.IOException;
22: import java.net.InetAddress;
23: import java.net.Proxy;
24:
25: /**
26: * This class was added so we can create sockets without options that were
27: * needed for server sockets. It just overrides create so that we call new
28: * natives which only set the options required for plain sockets. In order to
29: * preserve behaviour of older versions the create PlainSocketImpl was left as
30: * is and this new class was added. For newer versions an instance of this class
31: * is used, for earlier versions the original PlainSocketImpl is used.
32: */
33: class PlainSocketImpl2 extends PlainSocketImpl {
34:
35: public PlainSocketImpl2(FileDescriptor fd, int localport,
36: InetAddress addr, int port) {
37: super ();
38: super .fd = fd;
39: super .localport = localport;
40: super .address = addr;
41: super .port = port;
42: }
43:
44: public PlainSocketImpl2() {
45: super ();
46: }
47:
48: /**
49: * creates an instance with specified proxy.
50: */
51: public PlainSocketImpl2(Proxy proxy) {
52: super ();
53: this .proxy = proxy;
54: }
55:
56: @Override
57: protected void create(boolean isStreaming) throws IOException {
58: streaming = isStreaming;
59: if (isStreaming) {
60: netImpl.createSocket(fd, NetUtil.preferIPv4Stack());
61: } else {
62: netImpl.createDatagramSocket(fd, NetUtil.preferIPv4Stack());
63: }
64: }
65: }
|