簡體   English   中英

java.net.BindException:JVM綁定

[英]java.net.BindException:JVM Bind

我一直遇到此錯誤:“新ServerSocket上的異常:java.net.BindException:無法分配請求的地址:JVM_Bind”。 我嘗試使用netstat來確保端口(1500)上沒有任何運行。 有什么建議嗎?

package server;

import java.io.IOException
import java.net.InetAddress
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
public class Server 
{
private ServerSocket serverSocket;

Server(int Port)
{   
/* create socket server and wait for connection requests */
try 
{
        serverSocket = new ServerSocket(1500, 0, InetAddress.getByName("69.61.210.196"));
        System.out.println("Server waiting for client on port " + serverSocket.getLocalPort());
        while(true) 
        {
    Socket socket = serverSocket.accept();  // accept connection
    System.out.println("New client asked for a connection");
        }
    }
    catch (IOException e) 
    {
        System.out.println("Exception on new ServerSocket: " + e);
    }
}

    public static void main(String[] args) 
    {
       new Server(1500);
    }
}

聽起來您要綁定的IP地址是您網絡的外部IP地址,而不是您的機器IP。

建議嘗試改為綁定到127.0.0.10.0.0.0

要在Windows ipconfig和linux ifconfig上從命令行使用機器IP。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM