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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:14:37+00:00 2026-06-09T01:14:37+00:00

I am using TCP/IP sockets to create a client and server applicaton. Originally I

  • 0

I am using TCP/IP sockets to create a client and server applicaton. Originally I was using regular sockets but now I have decided to use SSL for my connection. I have created a keystore and have tried running my application but it has yet to be successful.

Here is my code for the server

public class ArFileServer {

public static void main(String[] args) 
{
    boolean listening = true;
    ServerSocketFactory serversocketfactory;
    ServerSocket serverSocket;  

    try
    {
        //serverSocket = new ServerSocket(4445);

        serversocketfactory = SSLServerSocketFactory.getDefault();
        serverSocket = serversocketfactory.createServerSocket(4445);

        String keystore = System.getProperty("javax.net.ssl.trustStore");
        System.out.println(keystore);

        // infinite loop to continually listen for connection requests made by clients
        while (listening)
        {
            new ClientConnection(serverSocket.accept()).start();

            if (serverSocket != null)
            {
                System.out.println("Connection to client established");
            }
        }

        serverSocket.close();
    }
    catch (IOException e)
    {
        System.out.println("Error could not create socket connection to port, check that port is not busy");
    }
}
}

and here is the client code:

public class ClientSocket 
{
SocketFactory socketfactory = null;
Socket clientSocket = null;
PrintWriter out = null;
BufferedReader in = null;


// establish a connection to All Care's server application through socket 4444 (adjust localhost to reflect the IP address that the server
// is being run from)
public ClientSocket()
{
    try
    {
        //clientSocket = new Socket("localhost", 4445);

        //SocketFactory socketfactory = SSLSocketFactory.getDefault();
        clientSocket = socketfactory.createSocket("192.168.1.8", 4445);
        out = new PrintWriter(clientSocket.getOutputStream(), true);
        in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

        String truststore = System.getProperty("javax.net.ssl.trustStore");
        System.out.println(truststore);
    }
    catch (IOException e)
    {
        System.out.println("Could not connect to All Care Server Application : " + e.getMessage());
    }
}
}

I am also using these runtime arguments:

-Djavax.net.ssl.keyStore=C:\Users\Chris\Documents\NetBeansProjects\ArFile\keystore.jks -Djavax.net.ssl.keyStorePassword=password

When I try to print out the truststore it always returns null, what am I doing wrong?

  • 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-09T01:14:39+00:00Added an answer on June 9, 2026 at 1:14 am

    When I try to print out the truststore it always returns null

    Because you never set it. All you are doing is printing out the value of a system property. If you didn’t set it, it is null.

    what am I doing wrong?

    Nothing yet, except printing out meaningless information. But much of your code doesn’t make sense:

    if (serverSocket != null)
    {
        System.out.println("Connection to client established");
    }
    

    serverSocket being non-null (a) is inevitable at this point, and (b) doesn’t have anything do with the client socket being established, which is inevitable at this point.

    catch (IOException e)
    {
        System.out.println("Error could not create socket connection to port, check that port is not busy");
    }
    

    An IOException at this point could mean many things, but the one thing it doesn’t mean is ‘cannot create socket connection to port’. It is the client that does the connecting: the server accepts connections. When you catch an exception, always print its message, don’t just make up your own.

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

Sidebar

Related Questions

I have a java server which is using TCP and sockets to connect to
I'm making an application server client using tcp sockets in c# .. The application
I have a server in linux using the Berkeley_sockets and I create a TCP
i am programing a client/server software in Python using sockets. I have a question,
I have developed a Java server using Eclipse that accepts TCP socket connection from
I implemented a TCP Client using a thread opening a socket to a server
My TCP server is implemented using Netty. My client using vanilla java.net.Socket to connect
In sockets I have written the client server program. First I tried to send
i have file transfer application (Server-Client) TCP [.net 4] why is backgroundworker gives me
I am trying to send multiple data from server to client using TCP. I

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.