equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
57 private BufferedOutputStream out; |
57 private BufferedOutputStream out; |
58 private BufferedInputStream in; |
58 private BufferedInputStream in; |
59 |
59 |
60 TCPClient(String hostname, int port, int timeout) |
60 TCPClient(String hostname, int port, int timeout) |
61 throws IOException { |
61 throws IOException { |
62 tcpSocket = new Socket(hostname, port); |
62 tcpSocket = new Socket(); |
|
63 tcpSocket.connect(new InetSocketAddress(hostname, port), timeout); |
63 out = new BufferedOutputStream(tcpSocket.getOutputStream()); |
64 out = new BufferedOutputStream(tcpSocket.getOutputStream()); |
64 in = new BufferedInputStream(tcpSocket.getInputStream()); |
65 in = new BufferedInputStream(tcpSocket.getInputStream()); |
65 tcpSocket.setSoTimeout(timeout); |
66 tcpSocket.setSoTimeout(timeout); |
66 } |
67 } |
67 |
68 |