Is it possible to make a web request using sockets? I am still studying about socket programming in and i wanted to upgrade my web request code using sockets.

Here is my web request code:

    Dim cweb As String = ""
    Dim POST As String = "sample post data"
    Dim request As HttpWebRequest
    Dim response As HttpWebResponse
    Dim tempCookies As New CookieContainer

        request = CType(WebRequest.Create(cweb), HttpWebRequest)
        request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0"
        request.AllowAutoRedirect = True
        request.ContentType = "application/x-www-form-urlencoded"
        request.ContentLength = POST.Length
        request.Method = "POST"
        request.KeepAlive = True
        request.CookieContainer = tempCookies

        Dim requestStream As Stream = request.GetRequestStream()
        Dim postBytes As Byte() = Encoding.ASCII.GetBytes(POST)
        requestStream.Write(postBytes, 0, postBytes.Length)

        response = CType(request.GetResponse(), HttpWebResponse)
        Dim postreader As New StreamReader(response.GetResponseStream())
        Dim thepage As String = postreader.ReadToEnd

Any samples or tips will be gladly accepted i really want to learn making a web request using sockets. Thanks in advance.

Here is a forum post in StackOverflow when a user posted information on this very subject!

I hope it helps!

yes I have seen that but i have no idea on how to make a post request method using sockets

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.