/[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.15 by mkoch, Thu Dec 19 12:21:58 2002 UTC revision 1.16 by mkoch, Thu Dec 19 14:39:59 2002 UTC
# Line 86  public class DatagramSocket Line 86  public class DatagramSocket
86    /**    /**
87     * This is the address we are "connected" to     * This is the address we are "connected" to
88     */     */
89    private InetAddress remote_addr;    private InetAddress remoteAddress;
90    
91    /**    /**
92     * This is the port we are "connected" to     * This is the port we are "connected" to
93     */     */
94    private int remote_port = -1;    private int remotePort = -1;
95    
96    /**    /**
97     * Is this a "connected" datagram socket?     * Is this a "connected" datagram socket?
98     */     */
99    private boolean connected = false;    private boolean connected = false;
100    
   // Constructors  
   
101    /**    /**
102     * Initializes a new instance of <code>DatagramSocket</code> that binds to     * Initializes a new instance of <code>DatagramSocket</code> that binds to
103     * a random port and every address on the local machine.     * a random port and every address on the local machine.
# Line 195  public class DatagramSocket Line 193  public class DatagramSocket
193     */     */
194    public InetAddress getInetAddress()    public InetAddress getInetAddress()
195    {    {
196      return remote_addr;      return remoteAddress;
197    }    }
198    
199    /**    /**
# Line 209  public class DatagramSocket Line 207  public class DatagramSocket
207     */     */
208    public int getPort()    public int getPort()
209    {    {
210      return remote_port;      return remotePort;
211    }    }
212    
213    /**    /**
# Line 220  public class DatagramSocket Line 218  public class DatagramSocket
218    public InetAddress getLocalAddress()    public InetAddress getLocalAddress()
219    {    {
220      if (impl == null)      if (impl == null)
221        return(null);        return null;
222    
223      // FIXME: According to libgcj, checkConnect() is supposed to be called      // FIXME: According to libgcj, checkConnect() is supposed to be called
224      // before performing this operation.  Problems: 1) We don't have the      // before performing this operation.  Problems: 1) We don't have the
# Line 256  public class DatagramSocket Line 254  public class DatagramSocket
254     */     */
255    public synchronized int getSoTimeout() throws SocketException    public synchronized int getSoTimeout() throws SocketException
256    {    {
257        if (impl == null)
258          throw new SocketException ("Cannot initialize Socket implementation");
259    
260      Object timeout = impl.getOption(SocketOptions.SO_TIMEOUT);      Object timeout = impl.getOption(SocketOptions.SO_TIMEOUT);
261    
262      if (timeout instanceof Integer)      if (timeout instanceof Integer)
# Line 296  public class DatagramSocket Line 297  public class DatagramSocket
297     */     */
298    public int getSendBufferSize() throws SocketException    public int getSendBufferSize() throws SocketException
299    {    {
300        if (impl == null)
301          throw new SocketException ("Cannot initialize Socket implementation");
302    
303      Object obj = impl.getOption(SocketOptions.SO_SNDBUF);      Object obj = impl.getOption(SocketOptions.SO_SNDBUF);
304    
305      if (obj instanceof Integer)      if (obj instanceof Integer)
# Line 337  public class DatagramSocket Line 341  public class DatagramSocket
341     */     */
342    public int getReceiveBufferSize() throws SocketException    public int getReceiveBufferSize() throws SocketException
343    {    {
344        if (impl == null)
345          throw new SocketException ("Cannot initialize Socket implementation");
346    
347      Object obj = impl.getOption(SocketOptions.SO_RCVBUF);      Object obj = impl.getOption(SocketOptions.SO_RCVBUF);
348        
349      if (obj instanceof Integer)      if (obj instanceof Integer)
# Line 393  public class DatagramSocket Line 400  public class DatagramSocket
400      if (sm != null)      if (sm != null)
401        sm.checkConnect(addr.getHostName(), port);        sm.checkConnect(addr.getHostName(), port);
402    
403      this.remote_addr = addr;      this.remoteAddress = addr;
404      this.remote_port = port;      this.remotePort = port;
405    
406      /* FIXME: Shit, we can't do this even though the OS supports it since this      /* FIXME: Shit, we can't do this even though the OS supports it since this
407         method isn't in DatagramSocketImpl. */         method isn't in DatagramSocketImpl. */
# Line 413  public class DatagramSocket Line 420  public class DatagramSocket
420    public void disconnect()    public void disconnect()
421    {    {
422      // FIXME: See my comments on connect()      // FIXME: See my comments on connect()
423      this.remote_addr = null;      this.remoteAddress = null;
424      this.remote_port = -1;      this.remotePort = -1;
425      connected = false;      connected = false;
426    }    }
427    
# Line 435  public class DatagramSocket Line 442  public class DatagramSocket
442        s.checkAccept(p.getAddress().getHostAddress(), p.getPort());        s.checkAccept(p.getAddress().getHostAddress(), p.getPort());
443    
444      impl.receive(p);      impl.receive(p);
445    
446        SecurityManager s = System.getSecurityManager();
447        if (s != null && isConnected ())
448          s.checkAccept (p.getAddress().getHostName (), p.getPort ());
449    }    }
450    
451    /**    /**
# Line 554  public class DatagramSocket Line 565  public class DatagramSocket
565     */     */
566    public boolean isConnected()    public boolean isConnected()
567    {    {
568      return remote_addr != null;      return remoteAddress != null;
569    }    }
570    
571    /**    /**
# Line 568  public class DatagramSocket Line 579  public class DatagramSocket
579      if (!isConnected ())      if (!isConnected ())
580        return null;        return null;
581    
582      return new InetSocketAddress (remote_addr, remote_port);      return new InetSocketAddress (remoteAddress, remotePort);
583    }    }
584    
585    /**    /**

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

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