diff options
Diffstat (limited to 'libjava/classpath/java/net/Socket.java')
-rw-r--r-- | libjava/classpath/java/net/Socket.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/libjava/classpath/java/net/Socket.java b/libjava/classpath/java/net/Socket.java index f4f25fe1c1b..64805274241 100644 --- a/libjava/classpath/java/net/Socket.java +++ b/libjava/classpath/java/net/Socket.java @@ -1,5 +1,5 @@ /* Socket.java -- Client socket implementation - Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2006 + Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -83,6 +83,12 @@ public class Socket SocketImpl impl; /** + * True if impl.create() has been called. + */ + // package-private because ServerSocket.implAccept() needs to access it. + boolean implCreated; + + /** * True if the socket is bound. * Package private so it can be set from ServerSocket when accept is called. */ @@ -326,11 +332,23 @@ public class Socket private SocketImpl getImpl() throws SocketException { + if (! implCreated) + { + try + { + impl.create(true); + } + catch (IOException x) + { + throw (SocketException) new SocketException().initCause(x); + } + implCreated = true; + } return impl; } /** - * Binds the socket to the givent local address/port + * Binds the socket to the given local address/port * * @param bindpoint The address/port to bind to * @@ -359,7 +377,6 @@ public class Socket // bind to address/port try { - getImpl().create(true); getImpl().bind(tmp.getAddress(), tmp.getPort()); bound = true; } |