Home Java Network Construct a DatagramSocket on an unspecified port



Construct a DatagramSocket on an unspecified port
Posted on: June 16, 2009 at 12:00 AM
In this section we are going to explain the process to construct a DatagramPacket object in more generic way.

Construct a DatagramSocket on an unspecified port

     

In this section we are going to explain the process to construct a DatagramPacket object in more generic way. Here we provide a complete example based on the method for creating the DatagramSocket object via DatagramSocket(). Firstly create a class DatagramSocketexample and initialize a object Client of DatagramSocket. Then we call DatagramSocket() method with new keyword. After that we use the try and catch block to know whether the code working correctly or not.

Here is the complete code of the Example :

import java.net.*;

public class DatagramSocketExample {
  public static void main(String[] args) {
  try {
  DatagramSocket Client = new DatagramSocket();
  System.out.println("datagram Socket recive at available port");
  }
  catch (SocketException exp) {
  }
  }
}

Here is the Output of the Example :

C:\roseindia>javac DatagramSocketExample.java

C:\
roseindia>java DatagramSocketExample
datagram Socket recive at available port

Download of  this example.

 

Related Tags for Construct a DatagramSocket on an unspecified port:
ccomidedataobjectsocketmethodsedvitagidforexamplerambaseexamecompleteinasdatagrammletjbasedasemeobjprocreatingxaxampssoatkmpleasocssthatijepleplpronomo


More Tutorials from this section

Ask Questions?    Discuss: Construct a DatagramSocket on an unspecified port  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.