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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:48:22+00:00 2026-05-13T16:48:22+00:00

Im making a listener which basically listens on a port for like forever and

  • 0

Im making a listener which basically listens on a port for like forever and as soon as a client connects it then initiates a transfer in a manner such that the listener first sends out a string “@AUTH@” and then the clien responds and so on.

My code segment for the above is as follows

while(true){


try {


    Socket incoming=connection.accept();
    while(!incoming.isClosed())
    { 
        out = new PrintWriter(incoming.getOutputStream(), true);
        in = new BufferedReader(new InputStreamReader(incoming.getInputStream()));
        BufferedInputStream is = new BufferedInputStream(incoming.getInputStream());    //inputstream to get data from the socket
        BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
        out.println("@AUTH@");
}
}
catch(Exception e){}
}

where ‘connection’ is an object of class ServerSocket.
Now when im testing my code using the hyoperterminal, im like connecting to the port and on the first connection, the string “@AUTH@” is displayed but then once i disconnect from that port using Hyperterminal and connect again, the string “@AUTH@” is not displayed. I basically want this string to be displayed every time a client connects to that port as it acts as the initiation for the whole authorization process.

Any pointers would be of great help.

CHeers

  • 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-13T16:48:22+00:00Added an answer on May 13, 2026 at 4:48 pm

    I suspect that the problem is that you’re not reading any data. If hyperterminal has sent anything (e.g. telnet negotiation codes) then there’s still data for you to read from the socket, so it probably isn’t treating it as being closed. Therefore your code is still dealing with the first connection, and won’t get round to accepting the new one.

    Aside from dealing with each connection more appropriately, you may wish to spawn a new thread for each connection – currently while one connection is “busy” you won’t be able to connect again, as you’ve already seen.

    You should be able to verify all of this using logging… logging which should also show if there have been any exceptions: catching Exception and swallowing it is going to make your life much harder in terms of working out what’s going on.

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

Sidebar

Related Questions

Making echo of a question around the web: Is the syntax for svn:ignore patterns
When making changes using SubmitChanges() , LINQ sometimes dies with a ChangeConflictException exception with
After making some changes in my models (eg. new field in a model and
After making a few modifications to a rails app I am tinkering on, railroad
Im making a small python script to upload files on the net. The script
I've been making a concerted effort to improve my javascript skills lately by reading
I am making a simple game in order to learn a new language. I
I'm thinking about making a networked game. I'm a little new to this, and
I have been making a little toy web application in C# along the lines
I'm making a WinForms app with a ListView set to detail so that several

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.