This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can https_client example receive packet from server side without sending request in advance?

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

Parents
  • 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.

    github.com/.../main.c

    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

    .

Reply Children
Related