14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 *
28 * (C) Copyright IBM Corp. 1999 All Rights Reserved.
29 * Copyright 1997 The Open Group Research Institute. All rights reserved.
30 */
31
32 package sun.security.krb5.internal;
33
34 import sun.misc.IOUtils;
35
36 import java.io.*;
37 import java.net.*;
38
39 public abstract class NetClient implements AutoCloseable {
40 public static NetClient getInstance(String protocol, String hostname, int port,
41 int timeout) throws IOException {
42 if (protocol.equals("TCP")) {
43 return new TCPClient(hostname, port, timeout);
44 } else {
45 return new UDPClient(hostname, port, timeout);
46 }
47 }
48
49 abstract public void send(byte[] data) throws IOException;
50 abstract public byte[] receive() throws IOException;
51 abstract public void close() throws IOException;
52 }
53
54 class TCPClient extends NetClient {
55
56 private Socket tcpSocket;
57 private BufferedOutputStream out;
|
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 *
28 * (C) Copyright IBM Corp. 1999 All Rights Reserved.
29 * Copyright 1997 The Open Group Research Institute. All rights reserved.
30 */
31
32 package sun.security.krb5.internal;
33
34 import java.io.*;
35 import java.net.*;
36 import sun.security.util.IOUtils;
37
38 public abstract class NetClient implements AutoCloseable {
39 public static NetClient getInstance(String protocol, String hostname, int port,
40 int timeout) throws IOException {
41 if (protocol.equals("TCP")) {
42 return new TCPClient(hostname, port, timeout);
43 } else {
44 return new UDPClient(hostname, port, timeout);
45 }
46 }
47
48 abstract public void send(byte[] data) throws IOException;
49 abstract public byte[] receive() throws IOException;
50 abstract public void close() throws IOException;
51 }
52
53 class TCPClient extends NetClient {
54
55 private Socket tcpSocket;
56 private BufferedOutputStream out;
|