提交 1cd70f84 编写于 作者: D dfuchs

8193596: java/net/DatagramPacket/ReuseBuf.java failed due to timeout

Summary: The test is changed to bind to InetAddress.getLocalHost() instead of binding to the wildcard.
Reviewed-by: alanb, dfuchs, msheppar
Contributed-by: NPatrick Concannon <catrick.concannon@oracle.com>
上级 92d23f46
/*
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -38,7 +38,9 @@ public class ReuseBuf {
DatagramSocket ds;
public ServerThread() {
try {
ds = new DatagramSocket();
InetAddress local = InetAddress.getLocalHost();
InetSocketAddress bindaddr = new InetSocketAddress(local, 0);
ds = new DatagramSocket(bindaddr);
port = ds.getLocalPort();
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
......@@ -68,7 +70,9 @@ public class ReuseBuf {
public static void main(String args[]) throws Exception {
ServerThread st = new ServerThread();
st.start();
DatagramSocket ds = new DatagramSocket();
InetAddress local = InetAddress.getLocalHost();
InetSocketAddress bindaddr = new InetSocketAddress(local, 0);
DatagramSocket ds = new DatagramSocket(bindaddr);
byte b[] = new byte[100];
DatagramPacket dp = new DatagramPacket(b,b.length);
for (int i = 0; i < msgs.length; i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册