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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:58:56+00:00 2026-06-11T18:58:56+00:00

I am doing socket programming. I have two files called Server.java and client.java. Both

  • 0

I am doing socket programming. I have two files called Server.java and client.java. Both programs were running successfully and successfully sending data to each other. Yesterday I added the following lines to client.java file:

     //old line
     out.writeUTF(dbdata); //dbdata was written successfully and sent to the server program
     try
     {
          //my socket connection object name is sock
            String data1="1000";
            System.out.println(data1);
            out.writeUTF(data1);   this line causes the error
     }

     catch(Exception e)
     {
            System.out.println("Exception :: "+e);
     }

When the line out.writeUTF(data1) is executed and catch catches it and shows the exception as BROKEN PIPE.

The contents of server.java which reads data1 is given below:

     String data1;
     try
     {
            data1=in.readUTF();
     }
     catch(Exception e)
     {
            System.out.println("Server Exception :: "+e);
     }

I also checked if connection is open with isConnected() before out.writeUTF(data1) and after the exception occurs in the catch I executed isConnected(). Both the times it showed True only.

  • 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-11T18:58:57+00:00Added an answer on June 11, 2026 at 6:58 pm

    @EJP is right. The exception means that the socket was closed before the write call could complete, and possibly before it started. There is no way of knowing how much of the data was delivered to the other end.

    The other part of the puzzle is why isConnected() is returning true. That is explained by the javadoc which says:

    “Note: Closing a socket doesn’t clear its connection state, which means this method will return true for a closed socket (see isClosed()) if it was successfuly connected prior to being closed.”

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

Sidebar

Related Questions

I'm doing some fairly simple cross-platform TCP socket programming. I have unfortunately found out
I have been doing socket programming for many years, but I have never had
I'm using node.js and socket.io and doing a server/client thing. On my Server, is
I'm doing some socket programming in Java and I'd like to be able to
I have a server socket that I setup, and a client socket that connects
im doing some basic socket programming in python. But im having some trouble figuring
`hi I am doing a simple synchronous socket programming,in which i employed twothreads one
I know you can’t add a class called Socket in VS2010 by doing: Right
I've been doing socket programming for a while in C++, and kind of got
I am trying my hands on Socket programming in C# (.NET). I have referred

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.