Java Doc for DatagramConnection.java in  » 6.0-JDK-Modules » j2me » javax » microedition » io » 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 » javax.microedition.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.microedition.io.DatagramConnection

All known Subclasses:   com.sun.cdc.io.j2me.datagram.Protocol,
DatagramConnection
public interface DatagramConnection extends Connection(Code)
This interface defines the capabilities that a datagram connection must have.

Reminder: Since the CLDC Specification does not define any actual network protocol implementations, the syntax for datagram addressing is not defined in the CLDC Specification. Rather, syntax definition takes place at the level of J2ME profiles such as MIDP.

In the sample implementation that is provided as part of the CLDC implementation, the following addressing scheme is used:

The parameter string describing the target of a connection in the CLDC implementation takes the following form:

 {protocol}://[{host}]:[{port}]
 
A datagram connection can be opened in a "client" mode or "server" mode. If the "//{host}" part is missing then the connection is opened as a "server" (by "server", we mean that a client application initiates communication). When the "//{host}" part is specified, the connection is opened as a "client".

Examples:

A datagram connection for accepting datagrams
datagram://:1234

A datagram connection for sending to a server:
datagram://123.456.789.12:1234

Note that the port number in "server mode" (unspecified host name) is that of the receiving port. The port number in "client mode" (host name specified) is that of the target port. The reply-to port in both cases is never unspecified. In "server mode", the same port number is used for both receiving and sending. In "client mode", the reply-to port is always dynamically allocated.

Also note that the allocation of datagram objects is done in a more abstract way than in Java 2 Standard Edition (J2SE). Instead of providing a concrete DatagramPacket class, an abstract Datagram interface is provided. This is to allow a single platform to support several different datagram interfaces simultaneously. Datagram objects must be allocated by calling the newDatagram methods of the DatagramConnection object. The resulting object is defined using another interface type called javax.microedition.io.Datagram.
version:
   12/17/01 (CLDC 1.1)
since:
   CLDC 1.0





Method Summary
public  intgetMaximumLength()
     Get the maximum length a datagram can be.
public  intgetNominalLength()
     Get the nominal length of a datagram.
public  DatagramnewDatagram(int size)
     Create a new datagram object.
public  DatagramnewDatagram(int size, String addr)
     Create a new datagram object.
public  DatagramnewDatagram(byte[] buf, int size)
     Create a new datagram object.
public  DatagramnewDatagram(byte[] buf, int size, String addr)
     Make a new datagram object.
public  voidreceive(Datagram dgram)
     Receive a datagram.
public  voidsend(Datagram dgram)
     Send a datagram.



Method Detail
getMaximumLength
public int getMaximumLength() throws IOException(Code)
Get the maximum length a datagram can be. Maximum length determines the maximum size of the datagram that can be created using the newDatagram method, and the maximum size of the datagram that can be sent or received. The maximum length of a datagram.
exception:
  IOException - If an I/O error occurs.



getNominalLength
public int getNominalLength() throws IOException(Code)
Get the nominal length of a datagram. Nominal length refers to the size of the datagram that is stored into the data buffer. Nominal length may be equal or less than the maximum length of the datagram. The nominal length of a datagram.
exception:
  IOException - If an I/O error occurs.



newDatagram
public Datagram newDatagram(int size) throws IOException(Code)
Create a new datagram object.
Parameters:
  size - The size of the buffer needed for the datagram A new datagram
exception:
  IOException - If an I/O error occurs.
exception:
  IllegalArgumentException - if the size is negativeor larger than the maximum size



newDatagram
public Datagram newDatagram(int size, String addr) throws IOException(Code)
Create a new datagram object.
Parameters:
  size - The size of the buffer neededfor the datagram
Parameters:
  addr - The I/O address to which the datagramwill be sent A new datagram
exception:
  IOException - If an I/O error occurs.
exception:
  IllegalArgumentException - if the size is negative orlarger than the maximum size, or if theaddress parameter is invalid



newDatagram
public Datagram newDatagram(byte[] buf, int size) throws IOException(Code)
Create a new datagram object.
Parameters:
  buf - The buffer to be used for the datagram
Parameters:
  size - The size of the buffer neededfor the datagram A new datagram
exception:
  IOException - If an I/O error occurs.
exception:
  IllegalArgumentException - if the size is negative orlarger than the maximum size or the givenbuffer's length, or if the buffer parameter is invalid



newDatagram
public Datagram newDatagram(byte[] buf, int size, String addr) throws IOException(Code)
Make a new datagram object.
Parameters:
  buf - The buffer to be used for the datagram
Parameters:
  size - The size of the buffer neededfor the datagram
Parameters:
  addr - The I/O address to which the datagramwill be sent A new datagram
exception:
  IOException - If an I/O error occurs.
exception:
  IllegalArgumentException - if the size is negative orlarger than the maximum size or the givenbuffer's length, or if the address or buffer parameter is invalid



receive
public void receive(Datagram dgram) throws IOException(Code)
Receive a datagram. When this method returns, the internal buffer in the Datagram object is filled with the data received, starting at the location determined by the offset state variable, and the data is ready to be read using the methods of the DataInput interface.

This method blocks until a datagram is received. The internal length state variable in the Datagram object contains the length of the received datagram. If the received data is longer than the length of the internal buffer minus offset, data is truncated.

This method does not change the internal read/write state variable of the Datagram object. Use method Datagram.reset to change the pointer before reading if necessary.
Parameters:
  dgram - A datagram.
exception:
  IOException - If an I/O error occurs.
exception:
  InterruptedIOException - Timeout or interrupt occurred.




send
public void send(Datagram dgram) throws IOException(Code)
Send a datagram. The Datagram object includes the information indicating the data to be sent, its length, and the address of the receiver. The method sends length bytes starting at the current offset of the Datagram object, where length and offset are internal state variables of the Datagram object.
Parameters:
  dgram - A datagram.
exception:
  IOException - If an I/O error occurs.
exception:
  InterruptedIOException - Timeout or interrupt occurred.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.