gpt4 book ai didi

java - 组播错误: Multicast Address Not Found

转载 作者:行者123 更新时间:2023-12-01 18:04:20 29 4
gpt4 key购买 nike

我正在尝试创建一个 SOAP 客户端。但不断收到此错误。有什么想法吗?我尝试更改IP,但仍然出现同样的错误。

enter image description here

MulticastSocket.Java

  public void joinGroup(InetAddress mcastaddr) throws IOException {
if (isClosed()) {
throw new SocketException("Socket is closed");
}

checkAddress(mcastaddr, "joinGroup");
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkMulticast(mcastaddr);
}

if (!mcastaddr.isMulticastAddress()) {
throw new SocketException("Not a multicast address");
}

SOAPClient.java

public class MultiThread extends Thread implements ActionListener, KeyListener {
MulticastSocket socket;
DatagramPacket packet;

public MultiThread() throws IOException {
socket = new MulticastSocket(4446);
InetAddress group = InetAddress.getByName("122.57.153.213");
socket.joinGroup(group);
}

SOAPCLient.java @ 第 80 行

public SoapClient() throws IOException, RemoteException, NotBoundException, NamingException {      
setBackground(new Color(0, 153, 76));//three green lines on gui
JPanel rightSideLayout = new JPanel();//active clients
rightSideLayout.setBackground(Color.darkGray);
JPanel bottomPanel = new JPanel(new BorderLayout());//contains typing field and send button

JLabel label = new JLabel();
Font font = label.getFont();
Map attributes = font.getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
font = Font.getFont(attributes);
label.setFont(font);
label.setText("\tBhoo Online");
label.setForeground(Color.WHITE);

setLayout(new BorderLayout(10, 10));

sendButton = new JButton("Send");
sendButton.setPreferredSize(new Dimension(RIGHT_PANEL_WIDTH, 20));
line 80 sendButton.addActionListener(new MultiThread());
mainField = new JTextArea();

SOAPClient.java(主)

    public static void main(String[] args) throws IOException, InterruptedException, RemoteException, NotBoundException, NamingException {
JFrame frame = new JFrame("BhooChat Client");
SoapClient bhooChat = new SoapClient();
frame.add(bhooChat);

最佳答案

传递给 joinGroup 的 IP 地址不是有效的多播地址。

有效的 IPv4 多播地址范围为 224.0.0.1 - 239.255.255.255。

关于java - 组播错误: Multicast Address Not Found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37944623/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com