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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:05:24+00:00 2026-06-05T16:05:24+00:00

here is the server side code of my program, the problem is, its accepting

  • 0

here is the server side code of my program, the problem is, its accepting one client. when another client is connected, the isConnected method returns true, but the server does not gets the messages from the server. please help me as this is my first java program in netbeans, i have just finished studying core java.

class Conn extends Thread{
        ServerSocket ss;
        Socket s;
        public void run()
        {
            status.setText(status.getText()+"connecting");
            try{
            while(true)
            {
            s=new Socket();
            ss=new ServerSocket(3000);
            s=ss.accept();
            Read r=new Read(s);
            r.start();
            }
            }catch(Exception e){}
        }

    }
    class Read extends Thread{
        DataInputStream inp;
        PrintStream outp;
        String str;
        Read(Socket s)
        {
            try{
            inp=new DataInputStream(s.getInputStream());
            outp=new PrintStream(s.getOutputStream());
            }catch(Exception sd){}
        }
        public void run()
        {
                status.setText(status.getText()+"\nreading");
            try{
            while(true)
            {
                str=inp.readLine();
                chatwin.append(str);
                outp.println(str);
            }
            }catch(Exception er){}
        }

    }
  • 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-05T16:05:25+00:00Added an answer on June 5, 2026 at 4:05 pm

    Move the while logic after the assignment of ss.

    try 
    {
        ss = new ServerSocket(3000);
        while (ss.isBound())
        {
            s=ss.accept();
            Read r = new Read(s);
            r.start();
        }
    }
    

    Your problem is that you can’t do this multiple times:

    ss = new ServerSocket(3000);
    

    You’ve already created a ServerSocket that sits at port 3000, so when you try to make another one, it’ll try to bind itself to that socket, and not succeed because your first ss is still sitting there. You should only create one ServerSocket and grab socket connections off of that one ServerSocket as threads connect to it.

    Does this answer your questions?

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

Sidebar

Related Questions

So I am coding this client/server program. This code is from the client side.
I have some troubles with receiving data on server side. Here goes the code:
I'm trying to create a client-server program that send and receive a string (its
I would like to execute a program in .NET server side code. So far
I have a client/server program and applet. I will show the code below. Can
I am sending ajax request to the server as : Client Side Code :
Here's the quick background: I've got a client and a server program that are
Here's my client-side code: $(#grid).jqGrid({ url: /Entry/EntryListingByBreed/, datatype: json, mtype: POST, postData: { showId:
I am using the tutorial laid out here http://www.androidsnippets.com/vbnet-server-side-code-to-send-c2dm-messages to attempt to send a
I'm writting a client(Android) - server(c#) application. I get the code from here: How

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.