@all i later get to solve this problem myself after careful studying and analyzing the chunked data. Here is my chunkResponseReader sub maybe it may be of great help to another person.
Sub chunkResponseReader(ByVal incoming As TcpClient, ByVal outgoing As TcpClient, ByVal client As NetworkStream, ByVal server As NetworkStream)
While True
Try
Dim res_hdr As String = ""
Dim agw As Integer
Dim php(0) As Byte
Dim chunkSize As Integer
Dim buffer() As Byte
While True
agw = server.Read(php, 0, php.Length)
res_hdr = res_hdr & Encoding.ASCII.GetString(php, 0, agw)
If res_hdr.IndexOf(vbCrLf) <> -1 Then
Exit While
End If
If agw = 0 Then
outgoing.Close()
incoming.Close()
Exit Sub
End If
received += agw
End While
totalTransfer = sent + received
agw = 0
chunkSize = CInt(convertHex(res_hdr.Substring(0, res_hdr.IndexOf(vbCrLf))))
Dim chunkRemain As Integer = 0
ReDim buffer(chunkSize - 1)
Dim res_hd As String
While True
agw = server.Read(buffer, 0, buffer.Length)
If agw = 0 Then
incoming.Close()
outgoing.Close()
Exit Sub
End If
client.Write(buffer, 0, agw)
res_hd = Encoding.ASCII.GetString(buffer, 0, agw)
received += agw
chunkRemain = (chunkSize + 0) - agw
chunkSize = chunkRemain
If chunkRemain <= 0 Then
Dim chunkEOF As String = ""
Dim agws As Integer = 0
While True
agws = server.Read(php, 0, php.Length)
chunkEOF = chunkEOF & Encoding.ASCII.GetString(php, 0, agws)
If chunkEOF.IndexOf(vbCrLf) <> -1 Then
Exit While
End If
received += agws
End While
Exit While
Else
ReDim buffer(chunkRemain - 1)
End If
End While
msg("Chunk :: DONE!")
Catch ex As Exception
msg("Chunk Response Reader Sub :: " & ex.Message)
incoming.Close()
outgoing.Close()
Exit While
End Try
End While
End Sub
My convertHex function still remains the same.
Thanks