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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:40:10+00:00 2026-05-14T02:40:10+00:00

I have a tcp socket sending three lines like this out2.println(message1\n); out2.println(message2\n); out2.println(message3\n); and

  • 0

I have a tcp socket sending three lines like this

        out2.println("message1\n");
        out2.println("message2\n");
        out2.println("message3\n");

and another tco socket receiving and displaying these messages like this

        System.out.println(in.readLine());
        System.out.println(in.readLine());
        System.out.println(in.readLine());

but only the first message is recieved and displayed, anything I send after that is not.

edit: here is the code

    private void buttonActionPerformed(java.awt.event.ActionEvent evt) {                                       
    try {
        // TODO add your handling code here:
        String ipAddress = ipTextArea.getText();
        sourceSocket = new Socket(ipAddress,32323);
        out = new PrintWriter(sourceSocket.getOutputStream(), true);
        in = new BufferedReader(new InputStreamReader(sourceSocket.getInputStream()));
        System.out.println(in.readLine());
        System.out.println(in.readLine());
        System.out.println(in.readLine());
    } catch (UnknownHostException ex) {
        Logger.getLogger(DESWashView.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(DESWashView.class.getName()).log(Level.SEVERE, null, ex);
    }


}       

cWashStations is also called from a button event:

public void cWashStations(){
Thread washThread = new Thread(){
    @Override
    public void run(){
        try {
            sSocket2 = new ServerSocket(32323);
            Thread stationThread = new Thread(){
                @Override
                public void run(){
                    try {
                        washSocket = sSocket2.accept();
                        out2 = new PrintWriter(washSocket.getOutputStream(), true);
                        in2 = new BufferedReader(new InputStreamReader(washSocket.getInputStream()));
                        out2.println("hello from attendant3423\n\n");
                        out2.flush();
                        out2.println("hello from attendant3423\n\n");
                        out2.println("1");
                        while(running){
                            }
                        } catch (IOException ex) {
                            Logger.getLogger(DESAttendantView.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                 };
                 stationThread.start();

            } catch (IOException ex) {
                Logger.getLogger(DESAttendantView.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    };
    washThread.start();
}
  • 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-14T02:40:11+00:00Added an answer on May 14, 2026 at 2:40 am

    If you use println() do not add \n at the end of string.

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

Sidebar

Related Questions

I have a class that encapsulates tcp socket communications with a server. For each
I have a worker thread that is listening to a TCP socket for incoming
I'm doing some fairly simple cross-platform TCP socket programming. I have unfortunately found out
I want to open a TCP client socket in Python. Do I have to
i am using pcap to create a packet sniffer. i have this tcp structure:
I have written a secure TCP server in .NET. This was basically as simple
I have a socket server, written in C++ using boost::asio, and I'm sending data
Hi i have got a TCP/IP Socket project. i can send string messages to
I've encountered an issue when sending large segments of data through a TCP socket,
I have a c# socket based server which serves TCP clients. I use telnet

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.