Source Code Cross Referenced for DatagramSocketImpl.java in  » 6.0-JDK-Modules » j2me » java » net » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » java.net 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)DatagramSocketImpl.java	1.27 06/10/10
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.  
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER  
006:         *   
007:         * This program is free software; you can redistribute it and/or  
008:         * modify it under the terms of the GNU General Public License version  
009:         * 2 only, as published by the Free Software Foundation.   
010:         *   
011:         * This program is distributed in the hope that it will be useful, but  
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of  
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  
014:         * General Public License version 2 for more details (a copy is  
015:         * included at /legal/license.txt).   
016:         *   
017:         * You should have received a copy of the GNU General Public License  
018:         * version 2 along with this work; if not, write to the Free Software  
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
020:         * 02110-1301 USA   
021:         *   
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa  
023:         * Clara, CA 95054 or visit www.sun.com if you need additional  
024:         * information or have any questions. 
025:         *
026:         */
027:
028:        package java.net;
029:
030:        import java.io.FileDescriptor;
031:        import java.io.IOException;
032:        import java.io.InterruptedIOException;
033:
034:        /**
035:         * Abstract datagram and multicast socket implementation base class.
036:         * @author Pavani Diwanji
037:         * @since  JDK1.1
038:         */
039:
040:        public abstract class DatagramSocketImpl implements  SocketOptions {
041:
042:            /**
043:             * The local port number.
044:             */
045:            protected int localPort;
046:
047:            /**
048:             * The file descriptor object.
049:             */
050:            protected FileDescriptor fd;
051:
052:            /**
053:             * Creates a datagram socket.
054:             * @exception SocketException if there is an error in the 
055:             * underlying protocol, such as a TCP error. 
056:             */
057:            protected abstract void create() throws SocketException;
058:
059:            /**
060:             * Binds a datagram socket to a local port and address.
061:             * @param lport the local port
062:             * @param laddr the local address
063:             * @exception SocketException if there is an error in the
064:             * underlying protocol, such as a TCP error.
065:             */
066:            protected abstract void bind(int lport, InetAddress laddr)
067:                    throws SocketException;
068:
069:            /**
070:             * Sends a datagram packet. The packet contains the data and the
071:             * destination address to send the packet to.
072:             * @param p the packet to be sent.
073:             * @exception IOException if an I/O exception occurs while sending the 
074:             * datagram packet.
075:             * @exception  PortUnreachableException may be thrown if the socket is connected
076:             * to a currently unreachable destination. Note, there is no guarantee that 
077:             * the exception will be thrown.
078:             */
079:            protected abstract void send(DatagramPacket p) throws IOException;
080:
081:            /**
082:             * Connects a datagram socket to a remote destination. This associates the remote
083:             * address with the local socket so that datagrams may only be sent to this destination
084:             * and received from this destination. This may be overridden to call a native
085:             * system connect. 
086:             *
087:             * <p>If the remote destination to which the socket is connected does not
088:             * exist, or is otherwise unreachable, and if an ICMP destination unreachable
089:             * packet has been received for that address, then a subsequent call to 
090:             * send or receive may throw a PortUnreachableException. 
091:             * Note, there is no guarantee that the exception will be thrown.
092:             * @param address the remote InetAddress to connect to
093:             * @param port the remote port number
094:             * @exception   SocketException may be thrown if the socket cannot be
095:             * connected to the remote destination
096:             * @since 1.4
097:             */
098:            protected void connect(InetAddress address, int port)
099:                    throws SocketException {
100:            }
101:
102:            /**
103:             * Disconnects a datagram socket from its remote destination. 
104:             * @since 1.4
105:             */
106:            protected void disconnect() {
107:            }
108:
109:            /**
110:             * Peek at the packet to see who it is from.
111:             * @param i an InetAddress object 
112:             * @return the address which the packet came from.
113:             * @exception IOException if an I/O exception occurs
114:             * @exception  PortUnreachableException may be thrown if the socket is connected
115:             *       to a currently unreachable destination. Note, there is no guarantee that the
116:             *       exception will be thrown.
117:             */
118:            protected abstract int peek(InetAddress i) throws IOException;
119:
120:            /**
121:             * Peek at the packet to see who it is from. The data is returned,
122:             * but not consumed, so that a subsequent peekData/receive operation 
123:             * will see the same data.
124:             * @param p the Packet Received.
125:             * @return the address which the packet came from.
126:             * @exception IOException if an I/O exception occurs
127:             * @exception  PortUnreachableException may be thrown if the socket is connected
128:             *       to a currently unreachable destination. Note, there is no guarantee that the
129:             *       exception will be thrown.
130:             * @since 1.4
131:             */
132:            protected abstract int peekData(DatagramPacket p)
133:                    throws IOException;
134:
135:            /**
136:             * Receive the datagram packet.
137:             * @param p the Packet Received.
138:             * @exception IOException if an I/O exception occurs
139:             * while receiving the datagram packet.
140:             * @exception  PortUnreachableException may be thrown if the socket is connected
141:             *       to a currently unreachable destination. Note, there is no guarantee that the
142:             *       exception will be thrown.
143:             */
144:            protected abstract void receive(DatagramPacket p)
145:                    throws IOException;
146:
147:            /**
148:             * Set the TTL (time-to-live) option.
149:             * param ttl a byte specifying the TTL value
150:             *
151:             * deprecated use setTimeToLive instead.
152:             * exception IOException if an I/O exception occurs while setting
153:             * the time-to-live option.
154:             * see #getTTL()
155:             *
156:            protected abstract void setTTL(byte ttl) throws IOException;
157:             */
158:
159:            /**
160:             * Retrieve the TTL (time-to-live) option.
161:             *
162:             * exception IOException if an I/O exception occurs
163:             * while retrieving the time-to-live option
164:             * deprecated use getTimeToLive instead.
165:             * return a byte representing the TTL value
166:             * see #setTTL(byte)
167:             *
168:            protected abstract byte getTTL() throws IOException;
169:             */
170:
171:            /**
172:             * Set the TTL (time-to-live) option.
173:             * @param ttl an <tt>int</tt> specifying the time-to-live value
174:             * @exception IOException if an I/O exception occurs
175:             * while setting the time-to-live option.
176:             * @see #getTimeToLive()
177:             */
178:            protected abstract void setTimeToLive(int ttl) throws IOException;
179:
180:            /**
181:             * Retrieve the TTL (time-to-live) option.
182:             * @exception IOException if an I/O exception occurs
183:             * while retrieving the time-to-live option
184:             * @return an <tt>int</tt> representing the time-to-live value
185:             * @see #setTimeToLive(int)
186:             */
187:            protected abstract int getTimeToLive() throws IOException;
188:
189:            /**
190:             * Join the multicast group.
191:             * @param inetaddr multicast address to join.
192:             * @exception IOException if an I/O exception occurs
193:             * while joining the multicast group.
194:             */
195:            protected abstract void join(InetAddress inetaddr)
196:                    throws IOException;
197:
198:            /**
199:             * Leave the multicast group.
200:             * @param inetaddr multicast address to leave.
201:             * @exception IOException if an I/O exception occurs
202:             * while leaving the multicast group.
203:             */
204:            protected abstract void leave(InetAddress inetaddr)
205:                    throws IOException;
206:
207:            /**
208:             * Join the multicast group.
209:             * @param mcastaddr address to join.
210:             * @param netIf specifies the local interface to receive multicast
211:             *        datagram packets
212:             * @throws IOException if an I/O exception occurs while joining
213:             * the multicast group
214:             * @since 1.4
215:             */
216:            protected abstract void joinGroup(SocketAddress mcastaddr,
217:                    NetworkInterface netIf) throws IOException;
218:
219:            /**
220:             * Leave the multicast group.
221:             * @param mcastaddr address to leave.
222:             * @param netIf specified the local interface to leave the group at
223:             * @throws IOException if an I/O exception occurs while leaving
224:             * the multicast group
225:             * @since 1.4
226:             */
227:            protected abstract void leaveGroup(SocketAddress mcastaddr,
228:                    NetworkInterface netIf) throws IOException;
229:
230:            /**
231:             * Close the socket.
232:             */
233:            protected abstract void close();
234:
235:            /**
236:             * Gets the local port.
237:             * @return an <tt>int</tt> representing the local port value
238:             */
239:            protected int getLocalPort() {
240:                return localPort;
241:            }
242:
243:            /**
244:             * Gets the datagram socket file descriptor.
245:             * @return a <tt>FileDescriptor</tt> object representing the datagram socket
246:             * file descriptor
247:             */
248:            protected FileDescriptor getFileDescriptor() {
249:                return fd;
250:            }
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.