AnsweredAssumed Answered

HTTP Client

Question asked by Priya Gupta on Sep 27, 2017
Latest reply on Sep 29, 2017 by Priya Gupta

Hello Everyone,

I wanted to create a HTTP client which can send request to and receive response from server using TWR-K60 and

TWR-SER2 tower boards with MQX RTOS 4.2.

I found this thread: TCP / IP Socket Client Issue (RTCS bug?) 

Based on the reference code attached with the above thread, i tried to setup the HTTP client and it worked for me.

-----------

But I would like to know, can I perform send() and receive() for multiple time by opening Socket connection only once?

(open connection only once, perform request/response multiple time, close the connection at the end)

I tried to debug the code and observed the TCP connection state (tcb->state) as follow:

bind() --> connect()

[ tcb->state = 1(i.e. SYN_SENT) after successful ACK, tcb->state = 3(i.e. ESTABLISHMENT)]

Send request -- send()  [tcb->state remains 3]

Receive response -- recv() [After receiving response tcb ->state changed to 6 (i.e. CLOSE_WAIT)]

 

Now, if I try to send another request, its unsuccessful, because server is in CLOSE_WAIT state.

Is there any API to keep server in ESTABLISHMENT state until Client closes the connection?

 

 

Your help will be really appreciated.

 

Thanks!!

Outcomes