Hi Nordic team
Current https_client example at sdk connect
Connect to server --> send http request to server --> Wait response from server
Can we receive packet from server directly?
If yes, how can I modify https_client example?
Thanks.
Jeff
Hi Nordic team
Current https_client example at sdk connect
Connect to server --> send http request to server --> Wait response from server
Can we receive packet from server directly?
If yes, how can I modify https_client example?
Thanks.
Jeff
Hi,
Can we receive packet from server directly?
No, that is not how HTTP(S) works.
HTTP is a request-response protocol, so you will never get a HTTP response from a server without first sending an HTTP request.
However, the sample is simply sending and receiving data (formatted as a HTTP request or response) over TCP, so you can use the same code as an example how to send or receive data over TCP.
So, if you set up a server to send data automatically when a client connects, you can use the same code that the sample uses to receive the HTTP response, without first sending the request.
Best regards,
Didrik
Hi Didrik
In order to directly receive packet from server side, I referred to below link for TCP sample.
Another question. At MQTT_simple, we can use callback function (mqtt_evt_handler()) to receive server packet.
When packet received, the event "MQTT_EVT_PUBLISH" was triggered. to read the packet content.
So, can we claim callback function to receive server packet at TCP sample? How to do?
Jeff
.
No, the TCP sample uses sockets directly. There are no libraries to register a callback to.
But you can make such a library yourself, with it's own read-loop or a poll function that must be called periodically.
Hi Didrik, I don't know how to make a library to set callback interrupt. Do you have guide documentation?
Hi Didrik, I don't know how to make a library to set callback interrupt. Do you have guide documentation?
What exactly is it that you want?
All you really need is a loop that reads, or polls, on the socket, and when it gets some data, calls a function through a function pointer.
You can then put the loop in a separate thread, so that it doesn't block the rest of the program.