Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20563

BASCOM-AVR : Socketstat strange results???? : NEWTOPIC

$
0
0
Warning long post...... Going to try and explain this anomaly without flooding with too much detail but yet enough to show the problem. Basis of problem: Socketstat is indicating that there is more data in the buffer than is what is comprehensible. FireFox w/ Firebug plug in verifies correct operation, not seeing proper response data in buffer in AVR. Platform is Arduino / EthernetShield(w5100). Do all the normal get socket, connect, etc up to this point all good. A request is sent to the connected server as follows: [code:1:79c237492e]GET / HTTP/1.1 Host: checkip.dyndns.org User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20100101 Firefox/21.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Connection: keep-alive Cache-Control: max-age=0 [/code:1:79c237492e] The code that performed the TCPread is as follows: [code:1:79c237492e] Function Server_ServerResponse(SocketNumber as byte, BytesRead as word) as byte local a as word local b as byte local e as byte e = false ' default return status to FALSE do a = Socketstat(SocketNumber , Sel_recv) ' get number of bytes waiting loop until a > 0 ' must wait for server to start sending data if a > 0 then b = Tcpread(SocketNumber , bytEthBuff(1), a) ' read line(s) BytesRead = a ' Pass number of bytes read in to buffer back to caller ' determine status to return to caller if b = 0 then e = true ' TCPread said xfer to buffer was good endif endif Server_ServerResponse = e 'pass status back to caller End Function [/code:1:79c237492e] Debug output from routine reports: length of strS=$00C1 Bytes Read=$0122 [code:1:79c237492e] Dim bytEthBuff(280) As Byte ' Ethernet recieve buffer Dim strS as string * 279 At bytEthBuff Overlay ' TCPIP buffer string / byte overlay [/code:1:79c237492e] The server's response is , so good so far... [code:1:79c237492e] HTTP/1.1 200 OK Content-Length: 100 Content-Encoding: gzip Content-Type: text/html Server: DynDNS-CheckIP/1.0 Cache-Control: no-cache Pragma: no-cache Connection: keep-alive [/code:1:79c237492e] So at this point strS has the response from the server all the way up to $C1 in the bytEthBuff. This where it starts to NOT make sense to me. The next lines are verbose debug output, hopefully it makes the point. The length of strS=$00C1 Bytes Read from the TCPread is=$0122. Here is a dump of bytEthBuff(1-122)..All good till $00BF. [code:1:79c237492e] Offset=$0001 = $48 = H Offset=$0002 = $54 = T Offset=$0003 = $54 = T Offset=$0004 = $50 = P Offset=$0005 = $2F = / Offset=$0006 = $31 = 1 Offset=$0007 = $2E = . Offset=$0008 = $31 = 1 Offset=$0009 = $20 = Offset=$000A = $32 = 2 Offset=$000B = $30 = 0 Offset=$000C = $30 = 0 Offset=$000D = $20 = Offset=$000E = $4F = O Offset=$000F = $4B = K Offset=$0010 = $0D = Offset=$0011 = $0A = Offset=$0012 = $43 = C Offset=$0013 = $6F = o Offset=$0014 = $6E = n Offset=$0015 = $74 = t Offset=$0016 = $65 = e Offset=$0017 = $6E = n Offset=$0018 = $74 = t Offset=$0019 = $2D = - Offset=$001A = $4C = L Offset=$001B = $65 = e Offset=$001C = $6E = n Offset=$001D = $67 = g Offset=$001E = $74 = t Offset=$001F = $68 = h Offset=$0020 = $3A = : Offset=$0021 = $20 = Offset=$0022 = $31 = 1 Offset=$0023 = $30 = 0 Offset=$0024 = $30 = 0 Offset=$0025 = $20 = Offset=$0026 = $20 = Offset=$0027 = $20 = Offset=$0028 = $20 = Offset=$0029 = $20 = Offset=$002A = $20 = Offset=$002B = $0D = Offset=$002C = $0A = Offset=$002D = $43 = C Offset=$002E = $6F = o Offset=$002F = $6E = n Offset=$0030 = $74 = t Offset=$0031 = $65 = e Offset=$0032 = $6E = n Offset=$0033 = $74 = t Offset=$0034 = $2D = - Offset=$0035 = $45 = E Offset=$0036 = $6E = n Offset=$0037 = $63 = c Offset=$0038 = $6F = o Offset=$0039 = $64 = d Offset=$003A = $69 = i Offset=$003B = $6E = n Offset=$003C = $67 = g Offset=$003D = $3A = : Offset=$003E = $20 = Offset=$003F = $67 = g Offset=$0040 = $7A = z Offset=$0041 = $69 = i Offset=$0042 = $70 = p Offset=$0043 = $0D = Offset=$0044 = $0A = Offset=$0045 = $43 = C Offset=$0046 = $6F = o Offset=$0047 = $6E = n Offset=$0048 = $74 = t Offset=$0049 = $65 = e Offset=$004A = $6E = n Offset=$004B = $74 = t Offset=$004C = $2D = - Offset=$004D = $54 = T Offset=$004E = $79 = y Offset=$004F = $70 = p Offset=$0050 = $65 = e Offset=$0051 = $3A = : Offset=$0052 = $20 = Offset=$0053 = $74 = t Offset=$0054 = $65 = e Offset=$0055 = $78 = x Offset=$0056 = $74 = t Offset=$0057 = $2F = / Offset=$0058 = $68 = h Offset=$0059 = $74 = t Offset=$005A = $6D = m Offset=$005B = $6C = l Offset=$005C = $0D = Offset=$005D = $0A = Offset=$005E = $53 = S Offset=$005F = $65 = e Offset=$0060 = $72 = r Offset=$0061 = $76 = v Offset=$0062 = $65 = e Offset=$0063 = $72 = r Offset=$0064 = $3A = : Offset=$0065 = $20 = Offset=$0066 = $44 = D Offset=$0067 = $79 = y Offset=$0068 = $6E = n Offset=$0069 = $44 = D Offset=$006A = $4E = N Offset=$006B = $53 = S Offset=$006C = $2D = - Offset=$006D = $43 = C Offset=$006E = $68 = h Offset=$006F = $65 = e Offset=$0070 = $63 = c Offset=$0071 = $6B = k Offset=$0072 = $49 = I Offset=$0073 = $50 = P Offset=$0074 = $2F = / Offset=$0075 = $31 = 1 Offset=$0076 = $2E = . Offset=$0077 = $30 = 0 Offset=$0078 = $0D = Offset=$0079 = $0A = Offset=$007A = $43 = C Offset=$007B = $61 = a Offset=$007C = $63 = c Offset=$007D = $68 = h Offset=$007E = $65 = e Offset=$007F = $2D = - Offset=$0080 = $43 = C Offset=$0081 = $6F = o Offset=$0082 = $6E = n Offset=$0083 = $74 = t Offset=$0084 = $72 = r Offset=$0085 = $6F = o Offset=$0086 = $6C = l Offset=$0087 = $3A = : Offset=$0088 = $20 = Offset=$0089 = $6E = n Offset=$008A = $6F = o Offset=$008B = $2D = - Offset=$008C = $63 = c Offset=$008D = $61 = a Offset=$008E = $63 = c Offset=$008F = $68 = h Offset=$0090 = $65 = e Offset=$0091 = $0D = Offset=$0092 = $0A = Offset=$0093 = $50 = P Offset=$0094 = $72 = r Offset=$0095 = $61 = a Offset=$0096 = $67 = g Offset=$0097 = $6D = m Offset=$0098 = $61 = a Offset=$0099 = $3A = : Offset=$009A = $20 = Offset=$009B = $6E = n Offset=$009C = $6F = o Offset=$009D = $2D = - Offset=$009E = $63 = c Offset=$009F = $61 = a Offset=$00A0 = $63 = c Offset=$00A1 = $68 = h Offset=$00A2 = $65 = e Offset=$00A3 = $0D = Offset=$00A4 = $0A = Offset=$00A5 = $43 = C Offset=$00A6 = $6F = o Offset=$00A7 = $6E = n Offset=$00A8 = $6E = n Offset=$00A9 = $65 = e Offset=$00AA = $63 = c Offset=$00AB = $74 = t Offset=$00AC = $69 = i Offset=$00AD = $6F = o Offset=$00AE = $6E = n Offset=$00AF = $3A = : Offset=$00B0 = $20 = Offset=$00B1 = $6B = k Offset=$00B2 = $65 = e Offset=$00B3 = $65 = e Offset=$00B4 = $70 = p Offset=$00B5 = $2D = - Offset=$00B6 = $61 = a Offset=$00B7 = $6C = l Offset=$00B8 = $69 = i Offset=$00B9 = $76 = v Offset=$00BA = $65 = e Offset=$00BB = $0D = Offset=$00BC = $0A = Offset=$00BD = $0D = Offset=$00BE = $0A = Offset=$00BF = $1F = Offset=$00C0 = $8B = Offset=$00C1 = $08 = Offset=$00C2 = <NULL> Offset=$00C3 = <NULL> Offset=$00C4 = <NULL> Offset=$00C5 = <NULL> Offset=$00C6 = <NULL> Offset=$00C7 = <NULL> Offset=$00C8 = $03 = Offset=$00C9 = $B3 = ³ Offset=$00CA = $C9 = É Offset=$00CB = $28 = ( Offset=$00CC = $C9 = É Offset=$00CD = $CD = Í Offset=$00CE = $B1 = ± Offset=$00CF = $B3 = ³ Offset=$00D0 = $C9 = É Offset=$00D1 = $48 = H Offset=$00D2 = $4D = M Offset=$00D3 = $4C = L Offset=$00D4 = $B1 = ± Offset=$00D5 = $B3 = ³ Offset=$00D6 = $29 = ) Offset=$00D7 = $C9 = É Offset=$00D8 = $2C = , Offset=$00D9 = $C9 = É Offset=$00DA = $49 = I Offset=$00DB = $B5 = µ Offset=$00DC = $73 = s Offset=$00DD = $2E = . Offset=$00DE = $2D = - Offset=$00DF = $2A = * Offset=$00E0 = $4A = J Offset=$00E1 = $CD = Í Offset=$00E2 = $2B = + Offset=$00E3 = $51 = Q Offset=$00E4 = $F0 = ð Offset=$00E5 = $0C = Offset=$00E6 = $50 = P Offset=$00E7 = $70 = p Offset=$00E8 = $CE = Î Offset=$00E9 = $48 = H Offset=$00EA = $4D = M Offset=$00EB = $CE = Î Offset=$00EC = $B6 = ¶ Offset=$00ED = $D1 = Ñ Offset=$00EE = $87 = Offset=$00EF = $88 = Offset=$00F0 = $DB = Û Offset=$00F1 = $E8 = è Offset=$00F2 = $43 = C Offset=$00F3 = $54 = T Offset=$00F4 = $25 = % Offset=$00F5 = $E5 = å Offset=$00F6 = $A7 = § Offset=$00F7 = $54 = T Offset=$00F8 = $22 = " Offset=$00F9 = $2B = + Offset=$00FA = $72 = r Offset=$00FB = $4C = L Offset=$00FC = $49 = I Offset=$00FD = $29 = ) Offset=$00FE = $4A = J Offset=$00FF = $2D = - Offset=$0100 = $2E = . Offset=$0101 = $B6 = ¶ Offset=$0102 = $52 = R Offset=$0103 = $30 = 0 Offset=$0104 = $33 = 3 Offset=$0105 = $D3 = Ó Offset=$0106 = $B3 = ³ Offset=$0107 = $30 = 0 Offset=$0108 = $D7 = × Offset=$0109 = $33 = 3 Offset=$010A = $34 = 4 Offset=$010B = $31 = 1 Offset=$010C = $D1 = Ñ Offset=$010D = $33 = 3 Offset=$010E = $34 = 4 Offset=$010F = $33 = 3 Offset=$0110 = $B7 = · Offset=$0111 = $D1 = Ñ Offset=$0112 = $07 = Offset=$0113 = $AB = « Offset=$0114 = $03 = Offset=$0115 = $6A = j Offset=$0116 = $02 = Offset=$0117 = $59 = Y Offset=$0118 = $A0 =   Offset=$0119 = <NULL> Offset=$011A = <NULL> Offset=$011B = $38 = 8 Offset=$011C = $90 = Offset=$011D = $42 = B Offset=$011E = $C5 = Å Offset=$011F = $68 = h Offset=$0120 = <NULL> Offset=$0121 = <NULL> Offset=$0122 = <NULL>[/code:1:79c237492e] The server TCPread response is good until offset $00BF. What is the data from $00BF-$0122? It is was verified in FireFox/Firebug that the response (HTML) was/is: [code:1:79c237492e] <html><head><title>Current IP Check</title></head><body>Current IP Address: xx.xx.51.195</body></html> [/code:1:79c237492e] I blanked out the first IP addresses from the response of the server here. No where is the HTML data present in the buffer from offset $00bf-$0122. It does take the server ~2 seconds to compute the Public IP from the initial request. So it is possible that maybe the TCPread call returned part of the servers response and I have to do another TCPread to get the HTML response. If that is the case, then why/what is all the extra data in the buffer from $00bf to $0122? I understand why strS was terminated at a length of $00c1, as it saw a NULL. $ bigstrings is declared as well. But where is the missing HTML and what is all of this garbage(??) in the buffer. None of which is displayed in the Firebug tool in FireFox. I don't understand....I know this is very verbose but hopefully someone stuck with me to the end here. TIA, Mark [b:79c237492e][color=red:79c237492e](BASCOM-AVR version : v2.0.7.7 , Latest : 2.0.7.6 )[/b:79c237492e][/color:79c237492e]

Viewing all articles
Browse latest Browse all 20563

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>