New Member FAQ | Forums | Earn Revenue | Posting Guidelines | Help Topics | Admissions 2013
Awards & Gifts
 
Login Login    Register      

ArticlesPractice TestsAsk ExpertsQuestion PapersJobsUniversitiesCollegesCoursesSchoolsTraining

Active Members
TodayLast 7 Daysmore...

Join our online Google+ community for Bloggers, Content Writers and Webmasters




Chat application in JAVA


Posted Date:     Total Responses: 0    Posted By: Bharath   Member Level: Gold   Points/Cash: 1   


DatagramClent.java

import java.net.*;
import java.io.*;

class DatagramClient
{
public static DatagramSocket ds; //Used to create the socket for communication
public static byte buffer[]=new byte[1024];

public static int clientport=789, serverport=790; //communication ports

public static void main(String args[]) throws Exception
{
ds=new DatagramSocket(clientport); //socket open on client port

System.out.println("Client is waiting for servder to send data");
System.out.println("Press Ctrl+C to come out");

while(true)
{
DatagramPacket dp=new DatagramPacket(buffer, buffer.length); //packets for receive the message
ds.receive(dp); //receive packets
String pdata=new String(dp.getData(),0, dp.getLength());
System.out.println(pdata);
}
}
}


DatagramServer.java


import java.net.*;
import java.io.*;

class DatagramServer
{
public static DatagramSocket ds; //used to create socket for communication
public static int clientport=789, serverport=790; //

public static void main(String args[]) throws Exception
{
byte buffer[]=new byte[1024];

ds=new DatagramSocket(serverport); //opens the socket on server port

BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));

System.out.println("Server is waiting for input");
InetAddress inet=InetAddress.getByName("localhost");

while(true)
{
String str=breader.readLine();
if(str==null || str.equals("End"))
break;
buffer=str.getBytes();

ds.send(new DatagramPacket(buffer, str.length(), inet,clientport)); //sends the packet on open client port
}
}
}





Project Feedbacks

Author: Member Level: BronzeRevenue Score: 2 out of 52 out of 5
yeah good one....but we cant choose this as final year projects for students this is a small application


Author: Member Level: GoldRevenue Score: 2 out of 52 out of 5
You can use it if you want to, but you have to make further modifications to this. Develop it, make it better.

All the best, Study well dude .


Author: Member Level: BronzeRevenue Score: 2 out of 52 out of 5
You can use it if you want to, but you have to make further modifications to this. Develop it, make it better.

All the best, Study well dude .


Author: Member Level: BronzeRevenue Score: 2 out of 52 out of 5
yeah good one....but we cant choose this as final year projects for students this is a small application


Post Feedback
You must Sign In to post a feedback.
Next Project: StockServer using Java Server component
Previous Project: GRAPHICS 2 dimension transformation in C

Return to Project Index

Post New Project


Related Projects

Subscribe to Email
  • Get Jobs by Email
  • Forum posts by Email
  • Articles by Email
  • Online Membersratna
    Pritan Tiwari
    Sanjay
    GOPINATH MISHRA
    shivani
    PODARALLA HARI KRISHNA
    Design Career
    bhaskar sen
    More...


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    AdSense Revenue Sharing sites   Advertise   Talk to Tony John
    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.