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 8143565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:09:09+00:00 2026-06-06T13:09:09+00:00

I have the following code: ServerSocket ss = new ServerSocket(2351); Socket s = ss.accept();

  • 0

I have the following code:

ServerSocket ss = new ServerSocket(2351);

Socket s = ss.accept();
InputStreamReader in = new InputStreamReader(s.getInputStream());
writer = new PrintWriter(s.getOutputStream());
writer.flush();

cbuf = new char[buf_length];
in.read(cbuf);
inputLine = new String(cbuf);

I ran four consecutive sends to my server and when I debug the above code it runs correctly three times. The other time the following is my inputLine that is read from the socket:

POST /record HTTP/1.1
Content-type: application/soap+xml;charset="utf-8";action=""
Accept: application/soap+xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
User-Agent: JAX-WS RI 2.1.5-b03-
Host: localhost:2351
Connection: keep-alive
Content-Length: 2197

And the content is just 2197 whitespaces instead of a 2197 length content. Its really weird and I am stuck. Any help is appreciated. Thanks.

  • 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-06-06T13:09:11+00:00Added an answer on June 6, 2026 at 1:09 pm

    I’ll try to make EJP’s answer more concrete. Instead of

    n.read(cbuf);
    inputLine = new String(cbuf);
    

    You need to do something like:

    StringBuilder sb = new StringBuilder();
    int charsRead;
    while ((charsRead = n.read(cbuf)) != -1) {
        sb.append(cbuf, 0, charsRead);
    }
    inputLine = sb.toString();
    

    This may not be the answer to the question you are asking, but it is definitely a bug in the code you posted.

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

Sidebar

Related Questions

I have the following code: Socket clientSocket = null; try { clientSocket = serverSocket.accept();
I have the following 3 lines of the code: ServerSocket listeningSocket = new ServerSocket(earPort);
I have created a socket using the following lines of code and i get
I have following code snipped: ... var tpc = new ThirtPartyClass(); tpc.ExecuteCommand(); tpc.ExecuteCommand(); ...
I have following code in C# PasswordDeriveBytes DerivedPassword = new PasswordDeriveBytes(Password, SaltValueBytes, HashAlgorithm, PasswordIterations);
I have following code in C# PasswordDeriveBytes DerivedPassword = new PasswordDeriveBytes(Password, SaltValueBytes, HashAlgorithm, PasswordIterations);
I have implement the following code to create a SSL server socket. public void
I have following code snippet in c#. var list = new List<string> { a,
I have following code snippet: self.xmlHttpReq = new XMLHttpRequest(); self.xmlHttpReq.onreadystatechange = function() { if(self.xmlHttpReq.readyState
I have the following code: if ( ( m_mainSocket = ::socket( PF_INET, SOCK_STREAM, IPPROTO_TCP

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.