home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / DatagramSocketImpl.java < prev    next >
Text File  |  1997-05-20  |  4KB  |  128 lines

  1. /*
  2.  * @(#)DatagramSocketImpl.java    1.10 97/01/25
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.net;
  24.  
  25. import java.io.FileDescriptor;
  26. import java.io.IOException;
  27. import java.io.InterruptedIOException;
  28.  
  29. /**
  30.  * Abstract datagram and multicast socket implementation base class.
  31.  * @author Pavani Diwanji
  32.  * @since  JDK1.1
  33.  */
  34.  
  35. public abstract class DatagramSocketImpl implements SocketOptions {
  36.     protected int localPort;
  37.  
  38.     /**
  39.      * The file descriptor object
  40.      * @since   JDK1.1
  41.      */
  42.     protected FileDescriptor fd;
  43.  
  44.  
  45.     /**
  46.      * Creates a datagram socket
  47.      * @since   JDK1.1
  48.      */
  49.     protected abstract void create() throws SocketException;
  50.  
  51.     /**
  52.      * Binds a datagram socket to a local port and address.
  53.      * @since   JDK1.1
  54.      */
  55.     protected abstract void bind(int lport, InetAddress laddr) throws SocketException;
  56.  
  57.     /**
  58.      * Sends a datagram packet. The packet contains the data and the
  59.      * destination address to send the packet to.
  60.      * @param packet to be sent.
  61.      * @since   JDK1.1
  62.      */
  63.     protected abstract void send(DatagramPacket p) throws IOException;
  64.  
  65.     /**
  66.      * Peek at the packet to see who it is from.
  67.      * @param return the address which the packet came from.
  68.      * @since   JDK1.1
  69.      */
  70.     protected abstract int peek(InetAddress i) throws IOException;
  71.  
  72.     /**
  73.      * Receive the datagram packet.
  74.      * @param Packet Received.
  75.      * @since   JDK1.1
  76.      */
  77.     protected abstract void receive(DatagramPacket p) throws IOException;
  78.  
  79.     /**
  80.      * Set the TTL (time-to-live) option.
  81.      * @param TTL to be set.
  82.      * @since   JDK1.1
  83.      */
  84.     protected abstract void setTTL(byte ttl) throws IOException;
  85.  
  86.     /**
  87.      * Retrieve the TTL (time-to-live) option.
  88.      * @since   JDK1.1
  89.      */
  90.     protected abstract byte getTTL() throws IOException;
  91.  
  92.     /**
  93.      * Join the multicast group.
  94.      * @param multicast address to join.
  95.      * @since   JDK1.1
  96.      */
  97.     protected abstract void join(InetAddress inetaddr) throws IOException;
  98.  
  99.     /**
  100.      * Leave the multicast group.
  101.      * @param multicast address to leave.
  102.      * @since   JDK1.1
  103.      */
  104.     protected abstract void leave(InetAddress inetaddr) throws IOException;
  105.  
  106.     /**
  107.      * Close the socket.
  108.      * @since   JDK1.1
  109.      */
  110.     protected abstract void close();
  111.  
  112.     /**
  113.      * Get the local port.
  114.      * @since   JDK1.1
  115.      */
  116.     protected int getLocalPort() {
  117.     return localPort;
  118.     }
  119.  
  120.     /**
  121.      * Get the datagram socket file descriptor
  122.      * @since   JDK1.1
  123.      */
  124.     protected FileDescriptor getFileDescriptor() {
  125.     return fd;
  126.     }
  127. }
  128.