[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in ServerSocket - accept()'s Socket is not bound? (3.4.3)
From: |
Andrew Haley |
Subject: |
Re: Bug in ServerSocket - accept()'s Socket is not bound? (3.4.3) |
Date: |
Thu, 21 Jul 2005 11:37:27 +0100 |
Martin Egholm Nielsen writes:
> Hi there,
>
> When I try the following piece of code:
>
> === 8< 8< 8< ===
>
> import java.io.IOException;
> import java.net.ServerSocket;
> import java.net.Socket;
>
> public class SocketBindTest
> {
> public static void main(String[] args) throws IOException
> {
> System.out.println("Accepting...");
> Socket s = new ServerSocket(80).accept();
> System.out.println(s.isBound());
> System.out.println(s.getLocalPort());
> System.out.println(s.getPort());
> } // main
> } // SocketBindTest
>
> === 8< 8< 8< ===
>
> I would expect the returned Socket instance, s, to be bound to same port
> as my server-socket - namely port 80. However, GCJ's Socket reports the
> socket as unbound, hence the port becomes "-1". A different behaviour is
> seen with Sun's...
It's a bug:
Breakpoint 1, SocketBindTest.main(java.lang.String[]) (address@hidden)
at SocketBindTest.java:11
(gdb) p _Jv_DeepDebug(socket,2)
address@hidden
{
boolean implCreated = false,
boolean outputShutdown = false,
java.net.SocketImpl impl = address@hidden
{
int localport = 80,
java.io.OutputStream out = null,
java.io.FileDescriptor fd = null,
int timeout = 0,
java.io.InputStream in = null,
java.net.InetAddress address = 0x15b840,
int native_fd = 15,
java.net.InetAddress localAddress = null,
int port = 41693,
boolean inChannelOperation = false,
},
boolean bound = false,
boolean inputShutdown = false,
}
As you can see, ServerSocket.accept doesn't set BOUND. I think the
right place to fix this is ServerSocket.implAccept().
Andrew.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Bug in ServerSocket - accept()'s Socket is not bound? (3.4.3),
Andrew Haley <=