-
Notifications
You must be signed in to change notification settings - Fork 96
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
How to keep receiving messages in server #126
Comments
Can you solve the problem? I have the same issue. |
No, but For now I am handling it from App side, like when I send message then I am disconnecting client from App and then again connecting it to send another message. |
Hi, I didn't really get the scenario here.. You want to have a server that accepts a client and reads multiple messages? Because your code only reads one message and then closes the connection... Please try to better explain the use case and the bug (if you think this is a bug). |
Yes, I want a server that accepts multiple messages until client is connected, But now When client connects to the server and sends a message after that if same client send another message it not listen by server, That's all I want is a server that accepts multiple messages. |
Sorry for being rude, but you have to know programming for working with this library... You probably don't expect me to write your code for you? You have most of the API documented in the Wiki and multiple simple and more complex examples as well as a README with examples from which you can understand the basics of how to work with clients and such... In the Wiki there is even an advanced example of working with multiple clients simultaneously. Meanwhile I will label the issue accordingly, maybe someone with some free time will write you an example specific to your case... Gil. |
I'm not saying to write any code for me, but I think you have not understood my question. I have checked wiki and your examples as well, but I am not saying to work with multiple clients, as your example your code listen to message and when it receives the message it close the connection and again steps repeat like another client connect and send the message, I have only one client but my client is not able to send multiple message that's what I am saying. In my code, client is connecting with server just one time, but If I refer your code, Then I need to connect my client again and again to server for sending multiple messages. My question is simple that I have to receive multiple messages from same client without repeating the client-server connection process. If you understand my question then just tell me what I am missing. Thank you |
@jaydip-pawar , you're calling @gilmaimon was right, you need to understand these basic aspects before raising any issue, it's about the code logic here, not the library itself. What you have there is an example, you have to adapt it based on your own needs :) |
Sorry, I thought I mentioned it in first question, But I tried with removing client.close() but still It's not working, That's why I asked. |
The same here. You can connect to the server, but when you send the first message, the server reply and then close the connection. |
@jaydip-pawar have you solved the issue? |
Not yet, I also tried other libraries for it but in my case I face many bugs so I tried with Bluetooth for transferring data and it's work fine with my code, So if you just want to transfer the data then try bluetooth instead of WiFi. |
I think that they must provide some working example, instead of asking to study the Basic programming concepts. |
Who are these "they" you mentioned 🤔 Your question has been answered, if you don't like the examples you can use another library, that will surely fix your problems. |
Where it was answered? |
Can you simply explain why the server close the connection even if you remove the client.close() line? |
Sorry for being rude but without answering to the answer and just closing the issue just because some arrogance is not good, rather than just arguing just answer it, simple! We use libraries doesn't mean we haven't any idea about programming just to save time we use it, but if someone ask questions or queries, rather than arguing give answer to them and improve your library by fixing any issue if there. |
Obviously the client instance is going out of scope so you can't interact with it anymore, so why would the connection stay open? The destructor is called and the connection is closed. If you want to keep interacting with the client you must keep interacting with the client object. If you let it go out of scope the connection will be closed (like any other RAII class). |
"Apology" not accepted... |
Right! But if object is declared globally and destructor is not called then why it's not interacting with client? Just after completing one loop client is disconnecting without calling client.close() |
That's the point, it's not declared globally. It's declared inside the function |
But I have tried it by declaring globally and it won't work, why? |
Without seeing the code I have no idea, but I assume you kept the loop code exactly as is so your client keep getting re-initialized (so the client keeps getting closed) These questions are symptoms of lacking experience in cpp and programming in general, which is why I think you should focus on those subjects before doing embedded and networking. You can be offended by this if you want, it's not arrogance. Even if I'll help you with your code line by line, you would still encounter other issues down the road, that has nothing to do with the library. I see that I already said that 2 months ago, if you would have invested the time in it, you could answer all of your questions yourself. |
Sorry but i don't think adding auto client = server.accept(); in setup re-initialise object with every loop iteration, and I would have been happy, If you had told me this earlier, I would have shown you my code and we would have reached to the conclusion. But no problem I have that much knowledge to find solutions and I found better solution over it, later but ok thanks for your valuable answers, it wouldn't help me but if someone encounter this issue It would be great if he could get his solution as you said if I'm wrong. |
This is my code and I want to listen multiple message from a Single client, but when I receive a message then It stops receiving messages and client.available() returning 0 after that, I have tried putting
client.poll();
in loop but It's not working.The text was updated successfully, but these errors were encountered: