Exception in thread "main" java.net.BindException:Address already in Use:jvm_bind

Source: Internet
Author: User

1 ImportJava.io.PrintStream;2 ImportJava.net.Socket;3 ImportJava.net.ServerSocket;4 ImportJava.util.Scanner;5 6  Public classServer7 {8      Public Static voidMain (string[] args)9         throwsExceptionTen     { OneServerSocket SS =NewServerSocket (30000); ASocket socket =ss.accept (); -PrintStream PS =NewPrintStream (Socket.getoutputstream ()); -Ps.println ("The first row of data for the server"); thePs.println ("Second row of data for server"); -         //closes the output stream of the socket, indicating that the output data has ended - socket.shutdownoutput (); -         //The following statement outputs false to indicate that the socket has not been closed.  + System.out.println (socket.isclosed ()); -Scanner scan =NewScanner (Socket.getinputstream ()); +          while(Scan.hasnextline ()) A         { at System.out.println (Scan.nextline ()); -         } - scan.close (); - socket.close (); - ss.close (); -     } in}
View Code

Running the above code, the following error occurred:

ServerSocket ss = new ServerSocket (30000);//error in this line, indicating that 30000 port is occupied, because there may be a program in the occupied 30000 port, you can change the end of the oral test!

Exception in thread "main" java.net.BindException:Address already in Use:jvm_bind

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.