-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add server_client example #5
Conversation
|
A lol, I also worked on examples but now I see you also did some. I noticed something too that it took long before an message was received further investigation needed. |
I did some test to monitor how long it took to send a message and it took 1 second. So there is some bug somewhere :) test results:
After debugging I found that And found out that acquiring the lock on
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be merged now. Should I add a comment to the example that it doesn't reflect the use-cases of this crate?
0ce5633
to
cd4a38a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice chat example, maybe not ideal for UDP but still fun example!. Further nice fix for that bug with the lock. I have tested how fast it was but it was way faster than before so looks good to me.
examples/server_client.rs
Outdated
stdin.read_line(&mut s)?; | ||
let line = s.replace(|x| x == '\n' || x == '\r', ""); | ||
|
||
socket.send(Packet::new(server, line.clone().into_bytes()))??; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, those are result wrapped results, most likely for non-blocking stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I'm not sure if the API is designed right here.
Ready for merge. |
* Add printlns, use SocketAddr::parse * Rename s to s_buffer
This is a stupid example, yes. I'm probably doing something wrong, because I noticed two issues: