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

Diff of /classpath/java/net/PlainDatagramSocketImpl.java

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

revision 1.12 by mkoch, Tue Jun 24 05:33:39 2003 UTC revision 1.13 by mkoch, Wed Jun 25 07:30:09 2003 UTC
# Line 55  import gnu.classpath.Configuration; Line 55  import gnu.classpath.Configuration;
55   * @author Aaron M. Renn <arenn@urbanophile.com>   * @author Aaron M. Renn <arenn@urbanophile.com>
56   * @author Warren Levy <warrenl@cygnus.com>   * @author Warren Levy <warrenl@cygnus.com>
57   */   */
58  public class PlainDatagramSocketImpl extends DatagramSocketImpl  class PlainDatagramSocketImpl extends DatagramSocketImpl
59  {  {
60    // Static initializer to load native library    // Static initializer to load native library
61    static    static
# Line 84  public class PlainDatagramSocketImpl ext Line 84  public class PlainDatagramSocketImpl ext
84    }    }
85    
86    /**    /**
87     * Creates a new datagram socket     * Binds this socket to a particular port and interface
88       *
89       * @param port The port to bind to
90       * @param addr The address to bind to
91     *     *
92     * @exception SocketException If an error occurs     * @exception SocketException If an error occurs
93     */     */
94    protected native synchronized void create() throws SocketException;    protected native synchronized void bind(int port, InetAddress addr)
95        throws SocketException;
96    
97    /**    /**
98     * Closes the socket     * Creates a new datagram socket
99       *
100       * @exception SocketException If an error occurs
101     */     */
102    protected native synchronized void close();    protected native synchronized void create() throws SocketException;
103    
104    /**    /**
105     * Binds this socket to a particular port and interface     * Sets the Time to Live value for the socket
106     *     *
107     * @param port The port to bind to     * @param ttl The new TTL value
    * @param addr The address to bind to  
108     *     *
109     * @exception SocketException If an error occurs     * @exception IOException If an error occurs
110     */     */
111    protected native synchronized void bind(int port, InetAddress addr)    protected synchronized void setTimeToLive(int ttl) throws IOException
112      throws SocketException;    {
113        setOption(IP_TTL, new Integer(ttl));
114      }
115    
116    /**    /**
117     * Sends a packet of data to a remote host     * Gets the Time to Live value for the socket
118     *     *
119     * @param packet The packet to send     * @return The TTL value
120     *     *
121     * @exception IOException If an error occurs     * @exception IOException If an error occurs
122     */     */
123    protected synchronized void send(DatagramPacket packet) throws IOException    protected synchronized int getTimeToLive() throws IOException
124    {    {
125      sendto(packet.getAddress(), packet.getPort(), packet.getData(),      Object obj = getOption(IP_TTL);
126             packet.getLength());  
127        if (!(obj instanceof Integer))
128          throw new IOException("Internal Error");
129    
130        return(((Integer)obj).intValue());
131    }    }
132    
133    /**    /**
# Line 134  public class PlainDatagramSocketImpl ext Line 145  public class PlainDatagramSocketImpl ext
145      throws IOException;      throws IOException;
146    
147    /**    /**
148     * What does this method really do?     * Sends a packet of data to a remote host
149       *
150       * @param packet The packet to send
151       *
152       * @exception IOException If an error occurs
153     */     */
154    protected synchronized int peek(InetAddress addr) throws IOException    protected synchronized void send(DatagramPacket packet) throws IOException
155    {    {
156      throw new IOException("Not Implemented Yet");      sendto(packet.getAddress(), packet.getPort(), packet.getData(),
157               packet.getLength());
158    }    }
159    
160    /**    /**
# Line 152  public class PlainDatagramSocketImpl ext Line 168  public class PlainDatagramSocketImpl ext
168      throws IOException;      throws IOException;
169    
170    /**    /**
171     * Joins a multicast group     * Sets the value of an option on the socket
172     *     *
173     * @param addr The group to join     * @param option_id The identifier of the option to set
174       * @param val The value of the option to set
175     *     *
176     * @exception IOException If an error occurs     * @exception SocketException If an error occurs
177     */     */
178    protected native synchronized void join(InetAddress addr) throws IOException;    public native synchronized void setOption(int option_id, Object val)
179        throws SocketException;
180    
181    /**    /**
182     * Leaves a multicast group     * Retrieves the value of an option on the socket
183     *     *
184     * @param addr The group to leave     * @param option_id The identifier of the option to retrieve
185     *     *
186     * @exception IOException If an error occurs     * @return The value of the option
187       *
188       * @exception SocketException If an error occurs
189     */     */
190    protected native synchronized void leave(InetAddress addr) throws IOException;    public native synchronized Object getOption(int option_id)
191        throws SocketException;
192    
193      /**
194       * Closes the socket
195       */
196      protected native synchronized void close();
197    
198    /**    /**
199     * Gets the Time to Live value for the socket     * Gets the Time to Live value for the socket
# Line 175  public class PlainDatagramSocketImpl ext Line 201  public class PlainDatagramSocketImpl ext
201     * @return The TTL value     * @return The TTL value
202     *     *
203     * @exception IOException If an error occurs     * @exception IOException If an error occurs
204       *
205       * @deprecated 1.2
206     */     */
207    protected synchronized byte getTTL() throws IOException    protected synchronized byte getTTL() throws IOException
208    {    {
# Line 192  public class PlainDatagramSocketImpl ext Line 220  public class PlainDatagramSocketImpl ext
220     * @param ttl The new TTL value     * @param ttl The new TTL value
221     *     *
222     * @exception IOException If an error occurs     * @exception IOException If an error occurs
223       *
224       * @deprecated 1.2
225     */     */
226    protected synchronized void setTTL(byte ttl) throws IOException    protected synchronized void setTTL(byte ttl) throws IOException
227    {    {
# Line 202  public class PlainDatagramSocketImpl ext Line 232  public class PlainDatagramSocketImpl ext
232    }    }
233    
234    /**    /**
235     * Gets the Time to Live value for the socket     * Joins a multicast group
236     *     *
237     * @return The TTL value     * @param addr The group to join
238     *     *
239     * @exception IOException If an error occurs     * @exception IOException If an error occurs
240     */     */
241    protected synchronized int getTimeToLive() throws IOException    protected native synchronized void join(InetAddress addr) throws IOException;
   {  
     Object obj = getOption(IP_TTL);  
   
     if (!(obj instanceof Integer))  
       throw new IOException("Internal Error");  
   
     return(((Integer)obj).intValue());  
   }  
242    
243    /**    /**
244     * Sets the Time to Live value for the socket     * Leaves a multicast group
245     *     *
246     * @param ttl The new TTL value     * @param addr The group to leave
247     *     *
248     * @exception IOException If an error occurs     * @exception IOException If an error occurs
249     */     */
250    protected synchronized void setTimeToLive(int ttl) throws IOException    protected native synchronized void leave(InetAddress addr) throws IOException;
   {  
     setOption(IP_TTL, new Integer(ttl));  
   }  
   
   /**  
    * Retrieves the value of an option on the socket  
    *  
    * @param option_id The identifier of the option to retrieve  
    *  
    * @return The value of the option  
    *  
    * @exception SocketException If an error occurs  
    */  
   public native synchronized Object getOption(int option_id)  
     throws SocketException;  
251    
252    /**    /**
253     * Sets the value of an option on the socket     * What does this method really do?
    *  
    * @param option_id The identifier of the option to set  
    * @param val The value of the option to set  
    *  
    * @exception SocketException If an error occurs  
254     */     */
255    public native synchronized void setOption(int option_id, Object val)    protected synchronized int peek(InetAddress addr) throws IOException
256      throws SocketException;    {
257        throw new IOException("Not Implemented Yet");
258      }
259    
260    public int peekData(DatagramPacket packet)    public int peekData(DatagramPacket packet)
261    {    {
# Line 270  public class PlainDatagramSocketImpl ext Line 274  public class PlainDatagramSocketImpl ext
274      throw new InternalError      throw new InternalError
275        ("PlainDatagramSocketImpl::leaveGroup is not implemented");        ("PlainDatagramSocketImpl::leaveGroup is not implemented");
276    }    }
277  } // class PlainDatagramSocketImpl  }

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