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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:10:32+00:00 2026-06-07T15:10:32+00:00

I have a sample TCP client and server application that I want to run

  • 0

I have a sample TCP client and server application that I want to run but I am not sure how to run them. It says I need to compile the client program in one host and the server application in another but I have no idea how to do this when I just have one computer. I know this is very simple but I need a little help to get me started.

Here is the sample TCP Server application:

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

class TCPServer {

public static void main(String argv[]) throws Exception 
{ 
  String clientSentence; 
  String capitalizedSentence;

  ServerSocket welcomeSocket = new ServerSocket(6790); 

  while(true) { 

               Socket connectionSocket = welcomeSocket.accept();

       BufferedReader inFromClient = 
         new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));

       DataOutputStream  outToClient = 
         new DataOutputStream(connectionSocket.getOutputStream());

       clientSentence = inFromClient.readLine();

       capitalizedSentence = clientSentence.toUpperCase() + '\n';

       outToClient.writeBytes(capitalizedSentence); 
    } 
} 
} 

Here is the sample TCPClient application

import java.io.*; 
import java.net.*; 
class TCPClient {

    public static void main(String argv[]) throws Exception 
    { 
        String sentence; 
        String modifiedSentence;

        BufferedReader inFromUser = 
          new BufferedReader(new InputStreamReader(System.in));

        Socket clientSocket = new Socket("10.0.1.2", 6790);

        DataOutputStream outToServer = 
          new DataOutputStream(clientSocket.getOutputStream());

        BufferedReader inFromServer = 
          new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

        sentence = inFromUser.readLine();

        outToServer.writeBytes(sentence + '\n');

        modifiedSentence = inFromServer.readLine();

        System.out.println("FROM SERVER: " + modifiedSentence);

        clientSocket.close(); 
                   
    } 
}

Is something off here?

Here is exactly what I do

step1
(source: skitch.com)

step2
(source: skitch.com)

This is the first time I use Eclipse so I could be doing something wrong there. I normally use DrJava but that didn’t let me run both at the same time for some reason.

  • 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-07T15:10:34+00:00Added an answer on June 7, 2026 at 3:10 pm

    Almost any socket program can run both halves on the same computer. Just run the server in one window, the client in another, and specify the connection address 127.0.0.1 (which means localhost, your own computer).

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

Sidebar

Related Questions

I have built a simple TCP server and need to compare client input with
I have two utilities written in C++, TCP/IP server and client that I have
I have a simple TCP socket client and server application. They are communicating using
I have been attempting to compile/run a sample WCF application from Juval Lowy's website
I have a small client server application in which i wish to send an
I have developed a TCP server by async pattern under .net4 in c# that
i make a simple TCP client/server in C# and i have the problem. When
I have a client that connects to server, starts sending binary data and when
I have a small sample program http://pastebin.com/5gFkaPgg that serves a REPL to a client
I have some simple questions, I have a client-server application and data sent on

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.