Read from web : Socket Web Client « Socket Network « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Socket Network » Socket Web Client 
22.11.2.Read from web
Imports System.Net.Sockets
Imports System.Net
Imports System.IO
Imports System.Text

Public Class Tester
    Public Shared Sub Main
        Dim httpReq As System.Net.HttpWebRequest
        Dim httpResp As System.Net.HttpWebResponse
    
        Dim respStream As Stream
        Dim respStreamReader As StreamReader
        Dim strBuff As String = Nothing
        Dim cbuffer(256As Char
        Dim byteRead As Integer = 0
        Dim index As Integer = 0
    
        Try
          Dim httpURL As New System.Uri("http://www.java2java.com")
    
          httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
          httpResp = CType(httpReq.GetResponse(), HttpWebResponse)
    
          respStream = httpResp.GetResponseStream()
          respStreamReader = New StreamReader(respStream, Encoding.UTF8)
    
          byteRead = respStreamReader.Read(cbuffer, 0256)
    
          While (byteRead <> 0)
            Dim strResp As New [String](cbuffer, 0, byteRead)
            Console.WriteLine(strResp)
            byteRead = respStreamReader.Read(cbuffer, 0256)
          End While
          respStream.Close()
        Catch ex As Exception
          Console.WriteLine(ex.StackTrace.ToString())
        End Try

    End Sub
End Class


     Java examples (example source code) Organized by topic