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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:10:07+00:00 2026-05-30T11:10:07+00:00

I recently learned about sockets in Java and sending information back and forth from

  • 0

I recently learned about sockets in Java and sending information back and forth from client to server through sockets.
What I want to achieve is sending ‘username’ and ‘password’ from client to server and then have these variables checked against the data in a database.

What would the best way be of sending the values of these two separate values to the server so that it can be verified server side?

client side

clientSocket = new Socket("192.168.56.1", 7777);

        in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
        out = new PrintWriter(clientSocket.getOutputStream(), true);


    //starting the thread
    while(runner == null)
    {
        runner = new Thread(this);

        runner.start();
    }
}
public void run()
{
    String userNameAdminLogin;
    String passwordAdminLogin;
    while(runner == Thread.currentThread())
    {
        userNameAdminLogin = txtUserName.getText();
        passwordAdminLogin = txtPassword.getText();

        out.println(userNameAdminLogin);
        out.println(passwordAdminLogin);
    }

sever side

while(listening)
            {
                clientSocket = ServerSoc.accept();


                in = new DataInputStream(clientSocket.getInputStream());

                BufferedReader is = new BufferedReader(new InputStreamReader(in));

                os = new PrintStream(clientSocket.getOutputStream());

                //How can I save the two seperate cases of data in variables on server side?
                System.out.println(is.readLine());

            }

Kind regards

Arian

  • 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-30T11:10:09+00:00Added an answer on May 30, 2026 at 11:10 am

    If you’re writing two lines on one side, you should obviously read two lines on the other side:

    String name = is.readLine();
    String password = is.readLine();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently, I started learning some Java. From what I've already learned about JVM it
I've recently learned core Java and want to develop my skills further with practice
I recently learned about CTE's in SQL Server and am attempting to use it
I just recently learned about the Properties class in java, and I'm trying to
I recently learned about Java's security model. Most people think Java is secure because
I recently learned scala and about to start working/learning Lift framework. Going through the
I recently learned about kayak , an HTTP server written in C# (i.e. not
I have recently learned about continuous integration. From my understanding, its a way to
I recently learned about the basic structure of the .docx file (it's a specially
I quite recently learned about the C++ classes friend keyword and the uses in

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.