Old client server tcp game

0

I'm going to use netbeans , and the program and what's at this link: #

First I run the server says: server is running then I run the client: and error appears on lines 28 and 187 but it does not say what type of error it is, the lines are these:

try
    {
        server = new ServerSocket(5000,2);  // <- linha 28 erro !
    }

and the other error is this:

public static void main( String args[] ) 
{
    JFrame.setDefaultLookAndFeelDecorated(true);
    TicTacToeServerProtocolo game = new TicTacToeServerProtocolo(); // <- erro 187 nesta linha !!
    game.execute();
}

Both errors are from the "TicTacToeClientProtocolo.java" program

Correct me if you are doing any wrong procedure. The game in question is the "Game of the Old one" as it is in the link that I provided of this site also, it is an equal question but relative to notepadd ++ but the objective is the same, ie, to work the server and the client at the same time (old game).

I know this code works (TicTacToe) because I saw it work on a friend of mine who gave me this code. He also used netbeans.

In the output "Output" exactly this message appears:

run:

java.net.BindException: Address already in use: JVM_Bind
    at java.net.DualStackPlainSocketImpl.bind0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:382)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
    at java.net.ServerSocket.bind(ServerSocket.java:375)
    at java.net.ServerSocket.<init>(ServerSocket.java:237)
    at java.net.ServerSocket.<init>(ServerSocket.java:181)
    at TicTacToeServerProtocolo.<init>(TicTacToeServerProtocolo.java:28)
    at TicTacToeServerProtocolo.main(TicTacToeServerProtocolo.java:187)

Java Result: 1

BUILD SUCCESSFUL (total time: 0 seconds)
    
asked by anonymous 06.06.2015 / 12:31

1 answer

1

This Address already in use: JVM_Bind error means that you already have an application running on that port, you need to either delete that application or change its port from 5000 to another higher value.

The higher, the lower the chance of being used.

To find out who is using this port you can do so:

Windows

  • Run resmon.exe
  • Networks Tab > Listening Ports
  • Linux

      

    netstat -tulpn

        
    06.06.2015 / 14:17