/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Abstract datagram and multicast socket implementation base class.
* Note: This is not a public class, so that applets cannot call
* into the implementation directly and hence cannot bypass the
* security checks present in the DatagramSocket and MulticastSocket
* classes.
*
* @author Pavani Diwanji
*/
{
/* timeout value for receive() */
boolean connected = false;
/* cached socket options */
private boolean loopbackMode = true;
);
/**
* flag set if the native connect() call not to be used
*/
/**
* Load net library into runtime.
*/
static {
}
/**
* Creates a datagram socket
*/
fd = new FileDescriptor();
try {
} catch (SocketException ioe) {
throw ioe;
}
}
/**
* Binds a datagram socket to a local port.
*/
throws SocketException {
}
throws SocketException;
/**
* Sends a datagram packet. The packet contains the data and the
* destination address to send the packet to.
* @param packet to be sent.
*/
/**
* Connects a datagram socket to a remote destination. This associates the remote
* address with the local socket so that datagrams may only be sent to this destination
* and received from this destination.
* @param address the remote InetAddress to connect to
* @param port the remote port number
*/
connected = true;
}
/**
* Disconnects a previously connected socket. Does nothing if the socket was
* not connected already.
*/
protected void disconnect() {
connected = false;
connectedPort = -1;
}
/**
* Peek at the packet to see who it is from.
* @param return the address which the packet came from.
*/
/**
* Receive the datagram packet.
* @param Packet Received.
*/
throws IOException {
receive0(p);
}
throws IOException;
/**
* Set the TTL (time-to-live) option.
* @param TTL to be set.
*/
/**
* Get the TTL (time-to-live) option.
*/
/**
* Set the TTL (time-to-live) option.
* @param TTL to be set.
*/
/**
* Get the TTL (time-to-live) option.
*/
/**
* Join the multicast group.
* @param multicast address to join.
*/
}
/**
* Leave the multicast group.
* @param multicast address to leave.
*/
}
/**
* Join the multicast group.
* @param multicast address to join.
* @param netIf specifies the local interface to receive multicast
* datagram packets
* @throws IllegalArgumentException if mcastaddr is null or is a
* SocketAddress subclass not supported by this socket
* @since 1.4
*/
throws IOException {
throw new IllegalArgumentException("Unsupported address type");
}
throws IOException;
/**
* Leave the multicast group.
* @param multicast address to leave.
* @param netIf specified the local interface to leave the group at
* @throws IllegalArgumentException if mcastaddr is null or is a
* SocketAddress subclass not supported by this socket
* @since 1.4
*/
throws IOException {
throw new IllegalArgumentException("Unsupported address type");
}
throws IOException;
/**
* Close the socket.
*/
protected void close() {
}
}
protected boolean isClosed() {
}
protected void finalize() {
close();
}
/**
* set a value - since we only support (setting) binary options
* here, o must be a Boolean
*/
if (isClosed()) {
throw new SocketException("Socket Closed");
}
switch (optID) {
/* check type safety b4 going native. These should never
* fail, since only java.Socket* has access to
* PlainSocketImpl.setOption().
*/
case SO_TIMEOUT:
throw new SocketException("bad argument for SO_TIMEOUT");
}
if (tmp < 0)
throw new IllegalArgumentException("timeout < 0");
return;
case IP_TOS:
throw new SocketException("bad argument for IP_TOS");
}
break;
case SO_REUSEADDR:
throw new SocketException("bad argument for SO_REUSEADDR");
}
break;
case SO_BROADCAST:
throw new SocketException("bad argument for SO_BROADCAST");
}
break;
case SO_BINDADDR:
throw new SocketException("Cannot re-bind Socket");
case SO_RCVBUF:
case SO_SNDBUF:
throw new SocketException("bad argument for SO_SNDBUF or " +
"SO_RCVBUF");
}
break;
case IP_MULTICAST_IF:
if (o == null || !(o instanceof InetAddress))
throw new SocketException("bad argument for IP_MULTICAST_IF");
break;
case IP_MULTICAST_IF2:
if (o == null || !(o instanceof NetworkInterface))
throw new SocketException("bad argument for IP_MULTICAST_IF2");
break;
case IP_MULTICAST_LOOP:
throw new SocketException("bad argument for IP_MULTICAST_LOOP");
break;
default:
}
socketSetOption(optID, o);
}
/*
* get option's state - set or not
*/
if (isClosed()) {
throw new SocketException("Socket Closed");
}
switch (optID) {
case SO_TIMEOUT:
break;
case IP_TOS:
}
break;
case SO_BINDADDR:
case IP_MULTICAST_IF:
case IP_MULTICAST_IF2:
case SO_RCVBUF:
case SO_SNDBUF:
case IP_MULTICAST_LOOP:
case SO_REUSEADDR:
case SO_BROADCAST:
break;
default:
}
return result;
}
protected abstract void datagramSocketClose();
throws SocketException;
protected boolean nativeConnectDisabled() {
return connectDisabled;
}
}