// $Id: ANEPSocketImpl.java,v 1.4 2001/01/08 13:09:31 sdalu Exp $

package java.net;

import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.SocketException;
import java.net.InetAddress;
import java.net.SocketOptions;

/**
 * Abstract ANEP datagram and multicast socket implementation base class.
 */ 
public abstract class ANEPSocketImpl implements SocketOptions {

    /**
     * The file descriptor object
     */
    protected FileDescriptor fd;

    protected int discardFlag;

    /**
     * Options that are allowed to be received
     * @param optionTypes array of option types
     */
    protected abstract void allowOptionTypes(int [] optionTypes) 
	throws SocketException;

    /**
     * Creates a datagram socket
     */
    protected abstract void create() throws SocketException;

    /**
     * Binds a datagram socket to a local port and address.
     */
    protected abstract void bind(int ltype, InetAddress laddr) 
	throws IOException;

    /**
     * Sends a datagram packet. The packet contains the data and the
     * destination address to send the packet to.
     * @param packet to be sent.
     */
    protected abstract void send(ANEPPacket p) throws IOException;

    /**
     * Peek at the packet to see who it is from.
     * @param return the address which the packet came from.
     */
    protected abstract int peek(InetAddress i) throws IOException;

    /**
     * Receive the datagram packet.
     * @param Packet Received.
     */
    protected abstract void receive(ANEPPacket p) throws IOException;

    /**
     * Set the TTL (time-to-live) option.
     * @param TTL to be set.
     */
    protected abstract void setHOPS(int hops) throws IOException;

    /**
     * Retrieve the TTL (time-to-live) option.
     */
    protected abstract int getHOPS() throws IOException;

    /**
     * Join the multicast group.
     * @param multicast address to join.
     */
    protected abstract void join(InetAddress inetaddr) throws IOException;

    /**
     * Leave the multicast group.
     * @param multicast address to leave.
     */
    protected abstract void leave(InetAddress inetaddr) throws IOException;

    /**
     * Close the socket.
     */
    protected abstract void close();


    /**
     * Get the ANEP socket file descriptor
     */
    protected FileDescriptor getFileDescriptor() {
        return fd;
    }
}
