summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib/socket/socket004.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/lib/socket/socket004.hs')
-rw-r--r--testsuite/tests/lib/socket/socket004.hs38
1 files changed, 38 insertions, 0 deletions
diff --git a/testsuite/tests/lib/socket/socket004.hs b/testsuite/tests/lib/socket/socket004.hs
new file mode 100644
index 0000000000..d7fbdc91bc
--- /dev/null
+++ b/testsuite/tests/lib/socket/socket004.hs
@@ -0,0 +1,38 @@
+{- client
+
+As for net002 but reads port number and message as arguments.
+It also prints out the IP number of the peer machine.
+
+
+
+TESTS:
+ getPeerName
+-}
+
+
+module Main(main) where
+
+import SocketPrim
+import System
+
+
+starbuck = "130.209.240.81"
+marcus = "130.209.247.2"
+
+nauru = "130.209.247.5" -- Linux 2.0.30 (RH-4.2) x86
+easter = "130.209.247.6" -- Linux 2.0.30 (RH-4.2) x86
+
+
+main =
+ getArgs >>= \ [port, message] ->
+ socket AF_INET Stream 6 >>= \ s ->
+ inet_addr easter >>= \ i_addr ->
+ connect s (SockAddrInet (mkPortNumber (read port)) i_addr) >>
+
+ getPeerName s >>= \ (SockAddrInet p haddr) ->
+ inet_ntoa haddr >>= \ a ->
+ putStr ("Connected to : " ++ a ++ "\n") >>
+ writeSocket s message >>
+ shutdown s ShutdownBoth >>
+ sClose s
+