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

tcp_server and tcp_client sample code not working properly #4378

Closed
wjmacfarland opened this issue May 4, 2017 · 4 comments
Closed

tcp_server and tcp_client sample code not working properly #4378

wjmacfarland opened this issue May 4, 2017 · 4 comments
Milestone

Comments

@wjmacfarland
Copy link

wjmacfarland commented May 4, 2017

When I run the sample programs "crystal tcp_server.cr" and then "crystal tcp_client.cr" The server receives the first message from the client, but the client hangs when attempting to read the response from the server. I've modified the tcp_server.cr so that the programs operate as what I believe should be expected, however there probably is a better way to do it than I have as I've just begun learning Crystal and have only limited Ruby experience. Here is the modified file. I am using Crystal 0.22 with Ubuntu 16.04.2 LTS.

@bcardiff
Copy link
Member

bcardiff commented May 4, 2017

@wjmacfarland thanks for reporting, I fixed by using IO#puts so the newline character is added and the tcp_client will read until it when doing the IO#gets.

@bcardiff bcardiff added this to the Next milestone May 4, 2017
@straight-shoota
Copy link
Member

Shouldn't IO#read_line (i.e. IO#gets) return the message with the terminating newline character included?

@Sija
Copy link
Contributor

Sija commented May 4, 2017

@straight-shoota Nope, it was changed in 0.20.3, see #3704.

@straight-shoota
Copy link
Member

Oh, thanks! Seems like I missed that change...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants