Checking Amount of Data Sent

ohkovar

Member
Licensed User
We have been having problems lately with AT&T Tilts not sending all the data to our server and we would like to check to see that the amount of data sent to the server equals the length of the data we wrote to the stream.

We are using the WebRequest and WebResponse along with a BinaryFile to write the data. Is there a way that I can determine exactly how many bytes reached the server?

Here's our current code (snippet):

Request.New1( pString )
Request.ContentType = "application/x-www-form-urlencoded"
Request.ContentLength = StrLength( "fake=1&values=" & pValues )
Request.Method = "POST"
Request.TimeOut = 30000 '30000 milliseconds = 30 seconds


bin.New1(Request.GetStream,True)

gBuffer() = bin.StringToBytes("fake=1&values=" & pValues )
bufLength = ArrayLen(gBuffer())
bin.WriteBytes (gBuffer())

Response.New1
Response.Value = Request.GetResponse
iResponse = Response.GetString
Response.close
 

Erel

Administrator
Staff member
Licensed User
I'm not sure I fully understand the problem.
However you should set ContentLength to the number of bytes sent which is bufLength.
It could be different than StrLength(...) if you are sending non (7 bit) ascii characters.
You will need to add a Bitwise object and use its StringToBytes method.
Afterward set the ContentLength.
 

ohkovar

Member
Licensed User
Perhaps I don't fully understand the way the data should be written to the server. I have piece-mealed this code together using examples and (personally) do not fully understand the concept of how the data is transmitted in this manner.

If there is an easier and better way to do it, I'd love to see it.
I am trying to send both GET and POST variables from the B4PPC program, which seems to work except that occasionally, our clients' data is being scrogged because of upload problems. I would like to know exactly how many bytes were tried and how many were actually sent to our server.

Thanks again!
 

Erel

Administrator
Staff member
Licensed User
The TCP/IP protocol is supposed to handle all data losses and resend the missing packets. Normally there should be no missing data.
There was a bug in your sending code where you set the contentLength incorrectly.
Try to do the change I wrote in my previous post.
 
Top