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

  • Home
  • SEARCH
  • 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 5845837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:29:31+00:00 2026-05-22T12:29:31+00:00

I have an app in java that is nothing but a remote server.The remote

  • 0

I have an app in java that is nothing but a remote server.The remote server I wanna design to accept two kinds of client:

1.Some that connect at 127.0.0.1 at the port 6000

2.The second type of client that connects at 127.0.0.1 at the port 6500

How do I do that???

I’ve tried the following:

public class Start {

    Socket socket=null;
    private String  serverIpAddress="127.0.0.1";
    static Thread cThread;
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        ThreadPooledServer server = new ThreadPooledServer(6000);
        new Thread(server).start();




        cThread = new Thread(new ClientThread());
        cThread.start();

    }

Where ThreadPooledServer and ClientThread are two different classes.

When I wanna start the second thread ….and that means this line:

cThread.start(); ….java tells me that “No enclosing instance of Start type is accessible!!!”

According to me it means that I cannot start two different threads in the same main…..Well,if I can’t do it this way…what is the proper way to do it?….to start two threads

1.That listen on the local machine to port 6000

2.Second that listen on the local machine at port 6500???

UPDATE: I wanna create a server that can listen on multiple ports and when I get a new connection, I want to be able to tell which port that connection used!!!!!!!!!!!!

  • 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-22T12:29:31+00:00Added an answer on May 22, 2026 at 12:29 pm

    If you want to listen on multiple ports in an efficiant way (=SingleThreaded) it may be a good idea to have a look at java.nio.SocketChannel and Selector, but I assume this is overkill for a low load scenario.

    Regarding the “No enclosing instance of type Start is accessible.”:

    Either create the treads in the constructor and create a new object of your class or declare the inner class static (if it does not need access to outer classes members)

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

Sidebar

Related Questions

I have a standalone Java app that has some licensing code that I want
I have the following Java socket client app, that sends same string to socket
I have a large Java app that is split up into multiple projects. Each
I have a rather large (80k loc) java desktop app that talks to a
I have been working for two years in software industry. Some things that have
I have some app ideas that I want to release for free (with ads).
I have an Eclipse RCP app running on Java 6. When I try to
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a
I have an app that needs to open a new window (in the same

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.