Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UNIXServer example in docs #5181

Merged
merged 3 commits into from Oct 26, 2017
Merged

Conversation

petoem
Copy link
Contributor

@petoem petoem commented Oct 24, 2017

The example is essentially the same as the TCPServer one. I verified both UNIXServer and UNIXSocket examples, they work.

/cc @bew

Copy link
Member

@asterite asterite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this example. If the first client doesn't send anything then no other client will be able to connect. There should be a spawn somewhere (same goes for the TCPServer example)

@bew
Copy link
Contributor

bew commented Oct 25, 2017

Agree @asterite

require "socket"

def handle_client(client)
  message = client.gets
  client.puts message
end

server = UNIXServer.new("/tmp/myapp.sock")
while client = server.accept?
  spawn handle_client(client)
end

More sth like this then?

@asterite
Copy link
Member

@bew I think so, yes :-)

@petoem
Copy link
Contributor Author

petoem commented Oct 25, 2017

@bew you are right, this is a more complete example. I change UNIXServer to it.
@asterite Can I fix TCPServer example in this PR too, or should I create a new/separate?

@asterite
Copy link
Member

@petoem Sure! You can fix it in this PR :-)

@RX14 RX14 added this to the Next milestone Oct 26, 2017
@RX14 RX14 merged commit df3399f into crystal-lang:master Oct 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants