Commit 087f741c4e56e2d715a1544282892036a8a31223

Authored by Alain Prouté
1 parent 8a96ce19

*** empty log message ***

Showing 1 changed file with 7 additions and 11 deletions   Show diff stats
anubis_dev/library/examples/client_server.anubis
... ... @@ -27,9 +27,6 @@
27 27 connect predefined.anubis
28 28  
29 29  
30   - This program is deliberately minimalist. However, it may serve as a basis for
31   - constructing an instant messaging system, with pseudonyms, centralized server, etc...
32   -
33 30  
34 31 *** Description.
35 32  
... ... @@ -67,11 +64,11 @@ define One
67 64 // "From 127.0.0.1:12345: ")
68 65 ) =
69 66 if *connection is // read one byte from the connection
70   - // (the handler waits for the next byte or the connection
  67 + // (this expression waits for the next byte or the connection
71 68 // is closed by the client)
72 69 {
73 70 failure then // the connection has been closed by the client
74   - print(from+" Connection closed by client.\n"),
  71 + print(from+"Connection closed by client.\n"),
75 72  
76 73 success(c) then // the byte 'c' has been read
77 74 if c = '\n'
... ... @@ -144,7 +141,7 @@ global define One
144 141 if args is
145 142 {
146 143 [ ] then server_syntax,
147   - [h . t] then
  144 + [h . _] then
148 145 if string_to_integer(h) is
149 146 {
150 147 failure then server_syntax,
... ... @@ -155,10 +152,9 @@ global define One
155 152 (One u) |-> u) is
156 153 {
157 154 cannot_create_the_socket then print("Cannot create the socket for listening.\n"),
158   - cannot_bind_to_port then print("Cannot bind to port "+h+"\n"),
159   - cannot_listen_on_port then print("Cannot listen on port "+h+"\n"),
160   - ok(server) then print("Simple Server started on port "+h+"\n")
161   -
  155 + cannot_bind_to_port then print("Cannot bind to port "+h+".\n"),
  156 + cannot_listen_on_port then print("Cannot listen on port "+h+".\n"),
  157 + ok(server) then print("Simple Server started on port "+h+".\n")
162 158 }
163 159 }
164 160 }.
... ... @@ -194,7 +190,7 @@ define One
194 190 within the program. It is exited only when 'anbexec' (of the client) is stopped by a
195 191 [Ctrl C]. Also notice that we must not forget to send "\n" appended to the
196 192 text. Otherwise, the server will wait indefinitely for the end of the line, and will
197   - print nothing. This "\n" is part of our 'transmission protocol'.
  193 + print nothing. This "\n" is part of our 'simple transmission protocol'.
198 194  
199 195  
200 196 The client program requires an IP address and port number in order to be able to find
... ...