Vote count:
0
I am very new to all this http thing and i am trying to make communication with a server. I need to do this (I need to write the client that post to server - i know what server returns but i am not sure how to send it the data): OK: 1) I (the client) Post XML to server at url: 192.168.2.111/senddata (i.e post /senddata) PROTOCOL : HTTP 2) Server response is: TCP: [ACK] Seq=1274 Ack=504 Win=525088 Len=0 I.E here is the problem - the server does not reply with HTTP reply. The protocol server uses after i send it the XML is TCP and this makes curl_easy_perform to not return. 3)After server TCP reply in step 2, i-the client should send binary data in a loop to server using: HTTP Continuation or non-HTTP traffic 4) Server asynchronicity answers with TCP: [ACK] Seq=1274 Ack=3424 Win=522176 Len=0 for each binary data sending .
curl_easy_setopt(mCurlHndl, CURLOPT_URL, "192.168.2.111");
curl_easy_setopt(mCurlHndl, CURLOPT_CUSTOMREQUEST, "POST /senddata");
curl_easy_setopt(mCurlHndl, CURLOPT_POST, 1L);
curl_easy_setopt(mCurlHndl, CURLOPT_POSTFIELDS, sXML.c_str());
curl_easy_setopt(mCurlHndl, CURLOPT_POSTFIELDSIZE, sXML.length());
headers = curl_slist_append(headers, "Content-Type: application/octet-stream");
headers = curl_slist_append(headers, "Accept:");
headers = curl_slist_append(headers, (string("Content-Length: ") + string(to_string(sXML.length()))).c_str());
curl_easy_setopt(mCurlHndl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(mCurlHndl);
Server does send in reply the: TCP: [ACK] Seq=1274 Ack=504 Win=525088 Len=0 (just with other seq/ack/win numbers of course).
OK, here starts the problems. a)curl_easy_perform does not return since (i think) server reply was not HTTP, but TCP. b)OK, lets say that i can bypass it giving Timeout curl_easy_setopt(mCurlHndl, CURLOPT_TIMEOUT_MS, 1000); But i just know that i am doing something wrong. c)Lets say i gave the timeout, now in step 3 i need to send in a loop stream of data. using HTTP Continuation or non-HTTP traffic. I do not know how to do that since it should not be regular post again like in step 1. It should be HTTP Continuation or non-HTTP traffic Sorry for my bad explanation but again it is from my very little experience in http. Seems that after step 1, server breaks that normal http connection rulls and what i need to send it is the binary data in a loop but again, i do not know how to do step 2 and 3. I.E how to get the tcp ack from server using curllib that i will know to move to step 3 and how to (step 3) send to server over the same connection (i think) the binary data in loop.
Thanks for any help!
Aucun commentaire:
Enregistrer un commentaire