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

More than one request per socket connection possible? #39

Closed
spamwax opened this issue Aug 6, 2019 · 1 comment
Closed

More than one request per socket connection possible? #39

spamwax opened this issue Aug 6, 2019 · 1 comment

Comments

@spamwax
Copy link

spamwax commented Aug 6, 2019

I am using this crate over standard librasy one mainly because of Read implementation.
I have two binary crates acting as server/client both of which use serde_json to serialize data.

After creating a unix-domain stream socket and connecting it to server's address, my client successfully uses socket.send() and reports back number of bytes sent.

However on server side the following never returns:

let (sock, addr) = server_socket.accept().unwrap();
let item: MyStrucnt = serde_json::from_read(sock).unwrap();

The only way I can force from_read to finish deserialization is to drop the socket on client side, which brings me to my question.
Is it possible to establish a socket connection between server/cli and communicate multiple messages back & forth between them while taking advantage of Read implementation in this crate? (I don't want to drop my client socket and re-create it every time I have to send a message accross!)

Confusing part for me is that the socket.send() on client side returns but seems server doesn't get the memo that payload is delivered & it's time to finish the deserialization operation.

How do you go about doing this type of communication?
Do I need to somehow attach an EOF to serialized data in client side to signal server?

Any input is appreciated.

@spamwax spamwax changed the title More than none request per socket connection possible? More than one request per socket connection possible? Aug 6, 2019
@alexcrichton
Copy link
Member

Thanks for the report! Unfortunately I don't have a ton of time to help out with networking knowledge in general, and this isn't a bug in this crate. For dealing with EOF I'd recommend looking into shutdown and various options that can enable.

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

2 participants