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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:17:57+00:00 2026-05-18T09:17:57+00:00

I am just working on my assignment of client-server and found an program online

  • 0

I am just working on my assignment of client-server and found an program online of a server.java as:

import java.io.*;
import java.net.*;

public class MyServer{

    public static void main(String [] args){
        try{
        ServerSocket ssc = new ServerSocket(7500);

        Socket newSsc = ssc.accept();
        DataInputStream din = new DataInputStream(newSsc.getInputStream());
        DataOutputStream dout = new DataOutputStream(newSsc.getOutputStream());

        PrintWriter pw = new PrintWriter(dout);
        pw.println("Hello! Welcome to vinit's server.");
        boolean more_data = true;
        while(more_data){
            String line = din.readLine();
            if(line == null){
                more_data = false;
            }
            else{
                pw.println("From Server "+line + "\n");
                System.out.println("From Client "+line);
                if(line.trim().equals("QUIT"))
                    more_data = false;
            }
        }
            newSsc.close();
        }
        catch(IOException e){
            System.out.println("IO error");

        }   

    }
}

THen after I used this server by typing the command as

$ telnet 127.0.0.1 7500

Now I want to ask how my server will be getting null from client, i mean what should be entered so that server will get null

Thanks in Advance.

  • 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-18T09:17:58+00:00Added an answer on May 18, 2026 at 9:17 am

    You have to gracefully close the TCP connection, simply CTRL+C or killing the telnet program won’t do, it’ll result in an exception in the Java code.

    This is a challenge with telnet, depending on your keyboard layout and OS.

    $ telnet localhost 8080
    Trying 127.0.0.1...
    Connected to localhost (127.0.0.1).
    Escape character is '^]'.
    ^]
    telnet> quit
    Connection closed.
    

    Basically, once inside telnet you’ll have to press the telnet escape key, which on my keyboard is CTRL+å and type quit , and on an US keyboard probably is what the telnet program tells you, just CTRL+]

    If you’re using the netcat program instead of telnet, you can just hit ctrl+d , or pipe some text to it, and the connection will be closed normally.

    echo "Some text" | nc localhost 7500
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a class assignment in C#, I came across a program crash without
I've just started working on an ASP.NET project which I hope to open source
I've just started working with ASP.NET MVC now that it's in beta. In my
I'm working on a homework assignment for my object oriented design class, and I'm
Some classmates and I are working on a homework assignment for Java that requires
I was just working on a function that I needed to return two values,
I just started working for a pretty large company and my group manages all
I have a Linq to SQL query that was working just fine with SQL
I just got done working through the Django tutorials for the second time, and
I have just been re-working an old bit of compiler-like code written using bison.

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.