1. /*
  2. * @(#)DatagramSocketImpl.java 1.15 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.net;
  8. import java.io.FileDescriptor;
  9. import java.io.IOException;
  10. import java.io.InterruptedIOException;
  11. /**
  12. * Abstract datagram and multicast socket implementation base class.
  13. * @author Pavani Diwanji
  14. * @since JDK1.1
  15. */
  16. public abstract class DatagramSocketImpl implements SocketOptions {
  17. protected int localPort;
  18. /**
  19. * The file descriptor object
  20. */
  21. protected FileDescriptor fd;
  22. /**
  23. * Creates a datagram socket
  24. */
  25. protected abstract void create() throws SocketException;
  26. /**
  27. * Binds a datagram socket to a local port and address.
  28. */
  29. protected abstract void bind(int lport, InetAddress laddr) throws SocketException;
  30. /**
  31. * Sends a datagram packet. The packet contains the data and the
  32. * destination address to send the packet to.
  33. * @param packet to be sent.
  34. */
  35. protected abstract void send(DatagramPacket p) throws IOException;
  36. /**
  37. * Peek at the packet to see who it is from.
  38. * @param return the address which the packet came from.
  39. */
  40. protected abstract int peek(InetAddress i) throws IOException;
  41. /**
  42. * Receive the datagram packet.
  43. * @param Packet Received.
  44. */
  45. protected abstract void receive(DatagramPacket p) throws IOException;
  46. /**
  47. * Set the TTL (time-to-live) option.
  48. * @param TTL to be set.
  49. *
  50. * @deprecated use setTimeToLive instead.
  51. */
  52. protected abstract void setTTL(byte ttl) throws IOException;
  53. /**
  54. * Retrieve the TTL (time-to-live) option.
  55. *
  56. * @deprecated use getTimeToLive instead.
  57. */
  58. protected abstract byte getTTL() throws IOException;
  59. /**
  60. * Set the TTL (time-to-live) option.
  61. * @param TTL to be set.
  62. */
  63. protected abstract void setTimeToLive(int ttl) throws IOException;
  64. /**
  65. * Retrieve the TTL (time-to-live) option.
  66. */
  67. protected abstract int getTimeToLive() throws IOException;
  68. /**
  69. * Join the multicast group.
  70. * @param multicast address to join.
  71. */
  72. protected abstract void join(InetAddress inetaddr) throws IOException;
  73. /**
  74. * Leave the multicast group.
  75. * @param multicast address to leave.
  76. */
  77. protected abstract void leave(InetAddress inetaddr) throws IOException;
  78. /**
  79. * Close the socket.
  80. */
  81. protected abstract void close();
  82. /**
  83. * Get the local port.
  84. */
  85. protected int getLocalPort() {
  86. return localPort;
  87. }
  88. /**
  89. * Get the datagram socket file descriptor
  90. */
  91. protected FileDescriptor getFileDescriptor() {
  92. return fd;
  93. }
  94. }