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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:54:38+00:00 2026-06-01T15:54:38+00:00

Solved: The problem was a virus or something similar that was hijacking the port.

  • 0

Solved:
The problem was a “virus” or something similar that was hijacking the port.
OBS: The virus hijacked the por in a way the port didn’t appear on netstat -an or TCPView of ports being used.

I used the AVG antivirus to remove the virus.
Another antivirus didn’t work, just AVG.


I did this program to check if a port is available:

package com.test;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.ServerSocket;

public class Test {
    public static void main(String[] args) {
        System.out.println("Port available: " + available(62974));
    }
    public static boolean available(int port) {
        ServerSocket ss = null;
    try {
        ss = new ServerSocket(port);
        ss.setReuseAddress(true);
        return true;
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (ss != null) {
            try {
                ss.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    return false;
    }
}

The response is false.

The exception thrown is:

java.net.BindException: Address already in use: JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
    at java.net.ServerSocket.bind(ServerSocket.java:328)
    at java.net.ServerSocket.<init>(ServerSocket.java:194)
    at java.net.ServerSocket.<init>(ServerSocket.java:106)
    at com.dgs.test.Test.available(Test.java:16)
    at com.dgs.test.Test.main(Test.java:9)

I’m using this port: 62974

But I check on Console/prompt-dos with:

netstat -ano 

The port is not on the list.

I’m not using any firewall, I deactivated it

Am I doing the right thing to see if the port is available?

Is this a “not usable” port?

  • 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-01T15:54:40+00:00Added an answer on June 1, 2026 at 3:54 pm

    You code should try to become a client rather than a server when testing an active TCP/UDP port either locally or remotely.

    package com.test;
    
    import java.io.IOException;
    import java.net.Socket;
    
    public class PortScan {
        public static void main(String[] args) {
            if (args.length > 0 ){
                System.out.println("Port active: " + available(args[0], args[1]));
            }
            else System.out.println("Usage: PortScan <ip> <port>");
        }
    
        public static boolean available(String ip, String port) {
            boolean status = false;
            Socket ss = null;
            try {
                ss = new Socket(ip, Integer.parseInt(port));
                status = true; //there is a listening port 
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (ss != null) {
                    try {
                        ss.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
    
            return status;
        }
    }
    

    Take this current nestat -ano result:

      TCP    192.168.72.1:139       0.0.0.0:0              LISTENING       4
      TCP    192.168.184.1:139      0.0.0.0:0              LISTENING       4
      UDP    0.0.0.0:445            *:*                                    4
    

    When there is already a UDP service is active but it is not listening at 127.0.0.1:445 or a TCP service is active and it is listening at 192.168.184.1:139, when you test PortScan 127.0.0.1 445 or PortScan 192.168.184.1 139, it will connect and say “Port active: true”:

    When there is no service at a given port (probably not active or blocked); let say “127.0.0.1:446”, it will catch a “Connection refused” and say “Port active: false”:

    java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(Unknown Source)
        at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at com.test.PortScan.available(PortScan.java:18)
        at com.test.PortScan.main(PortScan.java:9)
    Port active: false
    

    However, you will need to check why it is refusing; is it really not active or is it being blocked by a firewall? It is a tricky problem that you need to find out.

    After that, you can code to become a server and try to establish itself on a free/inactive port, like below:

            ServerSocket serverSocket = null;
            Socket socket = null;
            try {
                serverSocket = new ServerSocket(Integer.parseInt(port));
                serverSocket.setReceiveBufferSize(2048);
                serverSocket.setSoTimeout(0);
                serverSocket.setReuseAddress(true);
                socket = serverSocket.accept();
            } catch (NumberFormatException e1) {
                e1.printStackTrace();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
    
            //do something here in a loop
    
            try {
                socket.close();
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
    

    Update:

    Make sure the previous run (that involves the server code part) is closed properly in Eclipse when you are trying to connect again with another run. Check Debug view of Eclipse and close the offending previous run before testing. Otherwise, you will get a BindException when trying to establish a server code on the same port which is already active.

    To check whether the server port has been established, use:

    netstat -ano | find "62974"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Issue is SOLVED: Problem is that it is a pre-compiled web page project and
Updated Problem solved, I have some design problem here. The directory looks like that:
I have a similar problem as a previously solved problem of mine, except this
I imagine this is common enough that it's a solved problem, but being a
SOLVED - the problem is that doing a rotation puts half of the element
I solved Problem 10 of Project Euler with the following code, which works through
I can't see this in the docs, but I presume it's a solved problem.
Problem solved, see below Question I'm working in Flex Builder 3 and I have
(Problem solved now, see answers below) Hello, in my app I am trying to
[EDIT: Problem solved. Please see my answer below.] In my app I call the

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.