Skip to content

Commit

Permalink
Fix UNIXServer example in docs (#5181)
Browse files Browse the repository at this point in the history
* Fix example in docs for UNIXServer

* Improve UNIXServer example

* Fix TCPServer example in docs
  • Loading branch information
petoem authored and RX14 committed Oct 26, 2017
1 parent e602cd0 commit df3399f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/socket/tcp_server.cr
Expand Up @@ -6,12 +6,14 @@ require "./tcp_socket"
# ```
# require "socket"
#
# def handle_client(client)
# message = client.gets
# client.puts message
# end
#
# server = TCPServer.new("localhost", 1234)
# loop do
# server.accept do |client|
# message = client.gets
# client << message # echo the message back
# end
# while client = server.accept?
# spawn handle_client(client)
# end
# ```
#
Expand Down
10 changes: 8 additions & 2 deletions src/socket/unix_server.cr
Expand Up @@ -8,9 +8,15 @@ require "./unix_socket"
# ```
# require "socket"
#
# def handle_client(client)
# message = client.gets
# client.puts message
# end
#
# server = UNIXServer.new("/tmp/myapp.sock")
# message = server.gets
# server.puts message
# while client = server.accept?
# spawn handle_client(client)
# end
# ```
class UNIXServer < UNIXSocket
include Socket::Server
Expand Down

0 comments on commit df3399f

Please sign in to comment.