New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



WORKING OF UNICAST,MULTICAST,BROADCAST SESSIONS


Posted Date:     Total Responses: 0    Posted By: Rashina   Member Level: Gold   Points/Cash: 4   


WORKING OF UNICAST,MULTICAST,BROADCAST SESSIONS

SENDER

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

class cast
{
public static void main(String a[])throws Exception
{
DataInputStream d=new DataInputStream(System.in);
String id="";
String msg="msg from apl13";
char [][]grp=new char[20][20];
char [][]grp1=new char[20][20];
Socket s;
int j=0;
for(int i=11;i<=12;i++)
{
id="apl"+i;
grp[j++]= id.toCharArray();
}
j=0;
for(int i=13;i<=14;i++)
{
id="apl"+i;
grp1[j++]= id.toCharArray();
}System.out.println( grp[0]);
System.out.println( grp[1]);
System.out.println( grp1[0]);
System.out.println( grp1[1]);
System.out.println("Enter ur choice\n1->Unicast\n2-
>Multicast\n3->Broadcast");
int ch=Integer.parseInt(d.readLine());
switch(ch)
{
case 1:
System.out.println("UNICAST");
s=new Socket("apl13",80);
OutputStream os=s.getOutputStream();
ObjectOutputStream oos=new 
ObjectOutputStream(os);
System.out.println("Enter any msg");
msg=d.readLine();;
oos.writeObject(msg);
s.close();
break;
case 2:
System.out.println("Multicast");
System.out.println("Enter any msg");
msg=d.readLine();;
for(int i=0;i<2;i++)
{
id="";
for(j=0;j<5;j++)
id+=grp1[i][j];
s=new Socket(id,80);
os=s.getOutputStream();
oos=new ObjectOutputStream(os);
oos.writeObject(msg);
s.close();
}
break;
case 3:
System.out.println("BROADCAST");
System.out.println("Enter any msg");
msg=d.readLine();;

for(int i=0;i<2;i++)
{
id="";
for(j=0;j<5;j++)
id+=grp1[i][j];
s=new Socket(id,80);
os=s.getOutputStream();
oos=new ObjectOutputStream(os);
oos.writeObject(msg);
s.close();
}
for(int i=0;i<2;i++)
{
id="";
for(j=0;j<5;j++)
id+=grp[i][j];
s=new Socket(id,80);
os=s.getOutputStream();
oos=new ObjectOutputStream(os);
oos.writeObject(msg);
s.close();
}
break;

}

}
}

RECIEVER

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

class receiver
{
public static void main(String a[])throws Exception
{
String id;
ServerSocket s1=new ServerSocket(80);
Socket s;
InputStream is ;
ObjectInputStream ios ;
while(true)
{
s=s1.accept();
is=s.getInputStream();
ios=new ObjectInputStream(is);
System.out.println(ios.readObject());
}
}
}


Project Feedbacks


No feedbacks found. Be the first to respond and make money from revenue sharing program.

Post Feedback
You must Sign In to post a feedback.
Next Project: Merge Sort
Previous Project: Define a structure data type named 'date' containing three integer members day, month and year. Deve

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.