/[classpath]/classpath/java/net/DatagramSocket.java
ViewVC logotype

Diff of /classpath/java/net/DatagramSocket.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by mark, Tue Jan 22 22:27:00 2002 UTC revision 1.13 by mkoch, Sat Nov 23 10:29:28 2002 UTC
# Line 104  public class DatagramSocket Line 104  public class DatagramSocket
104     *     *
105     * @param port The local port number to bind to     * @param port The local port number to bind to
106     *     *
107       * @exception SecurityException If a security manager exists and its
108       * checkListen method doesn't allow the operation.
109     * @exception SocketException If an error occurs.     * @exception SocketException If an error occurs.
110     */     */
111    public DatagramSocket(int port) throws SocketException    public DatagramSocket(int port) throws SocketException
# Line 118  public class DatagramSocket Line 120  public class DatagramSocket
120     * @param port The local port number to bind to     * @param port The local port number to bind to
121     * @param laddr The local address to bind to     * @param laddr The local address to bind to
122     *     *
123       * @exception SecurityException If a security manager exists and its
124       * checkListen method doesn't allow the operation.
125     * @exception SocketException If an error occurs     * @exception SocketException If an error occurs
126     */     */
127    public DatagramSocket(int port, InetAddress laddr) throws SocketException    public DatagramSocket(int port, InetAddress laddr) throws SocketException
128    {    {
129      if (port < 0 || port > 65535)      this (new InetSocketAddress (laddr != null ? laddr : InetAddress.ANY_IF, port));
130        throw new IllegalArgumentException("Invalid port: " + port);    }
131    
132      /**
133       * Initializes a new instance of <code>DatagramSocket</code> that binds to
134       * the specified local port and address.
135       *
136       * @param port The local port number to bind to
137       * @param laddr The local address to bind to
138       *
139       * @exception SecurityException If a security manager exists and its
140       * checkListen method doesn't allow the operation.
141       * @exception SocketException If an error occurs
142       */
143      public DatagramSocket (SocketAddress address) throws SocketException
144      {
145        InetSocketAddress tmp = (InetSocketAddress) address;
146    
147      SecurityManager s = System.getSecurityManager();      SecurityManager s = System.getSecurityManager();
148      if (s != null)      if (s != null)
149        s.checkListen(port);        s.checkListen(tmp.getPort ());
150        
151      // Why is there no factory for this?      // Why is there no factory for this?
152      impl = new PlainDatagramSocketImpl();      impl = new PlainDatagramSocketImpl();
   
153      impl.create();      impl.create();
154    
155      if (laddr == null)      if (address != null)
156         laddr = InetAddress.ANY_IF;        {
157            local_addr = tmp.getAddress ();
158      local_addr = laddr;          impl.bind(tmp.getPort (), tmp.getAddress ());
159      impl.bind(port, laddr);        }
160    }    }
161    
162    /**    /**

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26