summaryrefslogtreecommitdiff
path: root/testsuite/java.net/SocketTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/java.net/SocketTest.java')
-rw-r--r--testsuite/java.net/SocketTest.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/testsuite/java.net/SocketTest.java b/testsuite/java.net/SocketTest.java
new file mode 100644
index 000000000..78a367b4d
--- /dev/null
+++ b/testsuite/java.net/SocketTest.java
@@ -0,0 +1,34 @@
+import java.net.*;
+
+public class SocketTest
+{
+ public static void main(String args[])
+ {
+ try {
+ Socket socket = new Socket("www.hungry.com", 80);
+
+ InetAddress remote = socket.getInetAddress();
+ InetAddress local = socket.getLocalAddress();
+
+ int rport = socket.getPort();
+ int lport = socket.getLocalPort();
+
+ socket.setSoTimeout(socket.getSoTimeout());
+ socket.setTcpNoDelay(socket.getTcpNoDelay());
+ int linger = socket.getSoLinger();
+ if (-1 != linger)
+ socket.setSoLinger(true, linger);
+ else
+ socket.setSoLinger(false, 0);
+
+ String socketString = socket.toString();
+ if (null == socketString)
+ throw new Exception("toString() failed");
+
+ socket.close();
+ System.out.println("PASSED: new Socket()" + socketString);
+ } catch (Exception e) {
+ System.out.println("FAILED: " + e);
+ }
+ }
+}