Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 606407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:15:04+00:00 2026-05-13T17:15:04+00:00

Following is the code that I’m using for reading data over a .NET socket.

  • 0

Following is the code that I’m using for reading data over a .NET socket. This piece of code is run by a single separate thread. It works OK the first time, on the second iteration it stops at “client.Receive(buffer)” and never recovers from it. Initially I was using recursion to read data but changed it to iteration thinking that recursion could be the source of problem. But apparently it is not.

Private Sub ReceiveSocket(ByVal client As Socket)

    Dim bytesRead As Integer = 0

    Do
        bytesRead = client.Receive(buffer)

        sb.Append(Encoding.ASCII.GetString(buffer, 0, bytesRead))

        Array.Clear(buffer, 0, buffer.Length)
    Loop While bytesRead > 0

End Sub 'ReceiveCallback

Why does it hang at Receive?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:15:04+00:00Added an answer on May 13, 2026 at 5:15 pm

    Well, that’s normal. The Receive() method won’t return until the server sends something else. Which it probably doesn’t do in your case until you ask it to send something else first. You should only call Receive() again if you didn’t get the full server response.

    Check the protocol specification. A server usually sends something that lets you tell that the full response was received. Like the number of bytes in the message. Or a special character at the end of the message. Linefeed (vbLf) is popular.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code that I originally found from this question: Prevent
I have the following code that fails when i run it. my .h file:
I have following code that I am compiling in a .NET 4.0 project namespace
I currently have the following code that retrieves data from the database and then
I have the following code that resides in my .js file //This is the
I have the following code that I have been using to Set properties in
i have the following code that adds data to unordered lists. The troublesome code
I have the following code that is hard coded <img src=data:image/png;base64,iVBORw0KGgoAAAANSUh .... > Through
I have the following code that is throwing this error but the solutions I've
I have the following code that sets a cookie: string locale = ((DropDownList)this.LoginUser.FindControl(locale)).SelectedValue; HttpCookie

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.