You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The client will consist of a single main function.
78
+
The client will consist of a single main function.[withSocketsDo](http://hackage.haskell.org/package/network-2.6.2.1/docs/Network-Socket-Internal.html#v:withSocketsDo) may be needed for Windows platform with old versions of network library. For compatibility with older versions on Windows, it is good practice to always call withSocketsDo (it's very cheap).
78
79
79
80
{% highlight haskell %}
80
81
main :: IO ()
81
-
main = do
82
+
main = withSocketsDo $ do
82
83
{% endhighlight %}
83
84
84
85
When we start the client we expect three command line arguments.
@@ -157,14 +158,14 @@ That's it! Here is the entire client again:
157
158
158
159
{% highlight haskell %}
159
160
main :: IO ()
160
-
main = do
161
+
main = withSocketsDo $ do
161
162
[host, port, serverAddr] <- getArgs
162
163
Right transport <- createTransport host port
163
164
Right endpoint <- newEndPoint transport
164
165
165
-
let addr = EndPointAddress (fromString serverAddr)
166
+
let addr = EndPointAddress (pack serverAddr)
166
167
Right conn <- connect endpoint addr ReliableOrdered defaultConnectHints
167
-
send conn [fromString "Hello world"]
168
+
send conn [pack "Hello world"]
168
169
close conn
169
170
170
171
replicateM_ 3 $ receive endpoint >>= print
@@ -180,7 +181,8 @@ start with a bunch of imports:
0 commit comments