Professional Documents
Culture Documents
# include<graphics.h> # include<stdio.h> # include<stdlib.h> #include<conio.h> Void main() { Intgdriver=DETECT, gmode,errorcode; Intleft,top,right,bottom; Intgraph(&gdriver,&gmode,c:\\tc\\bgc); rectangle(5,10,100,34); rectangle(500,10,600,34); rectangle(5,45,109,64); rectangle(5,79,100,198); rectangle(5,109,100,128); rectangle(5,142,100,160); rectangle(5,205,100,224); rectangle(500,45,609,64); rectangle(500,45,609,64); rectangle(500,79,600,96); rectangle(500,109,600,128); rectangle(500,142,600,160); rectangle(500 ,175,600,192); rectangle(1500,175,600,192); rectangle(500,205,600,224); rectangle(500,10,600,34); line(100,124,500,24); line(100,54,500,54); line(100,86,500,118); line(100,118,500,118); line(100,150,500,150); line(100,214,500,214); line(100,214,180,182); gotoxy(2,2);
1|P ag e
printf(application); gotoxy(2,2); printf(application); gotoxy(65,2); printf(application); gotoxy(2,4); printf(presentation); gotoxy(65,4); printf(presentation); gotoxy(2,6); printf(session); gotoxy(65,6); printf(session); gotoxy(2,8); printf(transport); gotoxy(65,8); printf(transport); gotoxy(65,8); printf(transport); gotoxy(2,10); printf(network); gotoxy(20,10); printf(network); gotoxy(45,10); printf(network); gotoxy(85,10); printf(network); gotoxy(2,12); printf(data link); gotoxy(20,12); printf(data link); gotoxy(65,12); printf(data link); gotoxy(35,3);
2|P ag e
printf(peer to peer); gotoxy(2,14); printf(physical); gotoxy(45,14); printf(physical); gotoxy(65,14); printf(physical); gotoxy(35,5); printf(peer to peer); gotoxy(35,7); printf(peer to peer); getch(); closegraph(); }
3|P ag e
nice
session
Frame j=newFrame(connection to Mr. XYZ+args[0]); ChatRoom12M client chat=new ChatRoom12MClient (j,args[0],args[1]); j.add(centre, chat); j.setSize(800,600); j.show(); chat.client(); } public ChatRoom12MClient(Frame,F,String, user,String sort ) { frame =j; frame.addWindowListener(new WindowEventHandler()); UserName=User; HostName=Host; c.inserts=inserts; c.grids=j; Lavel=new Lavel(Text to send); add(lavel); c.gridx=j; add(send text); Lavel=new Lavel(Text reciever); add(Lavel); receiver Text=new TextArea(15,30); add(receiver Text); ImageIcon i1=new ImageIcon(click.gif); ImageIcon i2=new ImageIcon(doorin.2.gif); send=new JButton(i1); ocit=new JButton(i2); add(send); add(exit); send.addActionListener(new TextActionHandler()); exit.addActionListener(new exit()); } void client() {
5|P ag e
try { if(hostname.equals(local)) hostname=null; InetAddress server Addr=InetAddress.getByName(hostName); sock=new Socket(server Addr.getHostName().port); remoteOut=new Data OutputStream(sock.getOutputStream()); System.out.println(Converted +sock.getPort()); } catch(IOException e) { System.out.println(e.set message() + : Failed to connect to server); } } Protected void finalize() throws throable { System.out.println(x.set message() + : connection to peer host ); } } } } class ChatRoom12MClient Receive(ChatRoom12MClient Chat) { this.chat=chat; } public Synchronized void run() { String s; DataInputStreamremotein=null try { remotein = new DataInputStream(chat.sock.getInputStream()); while(true)
6|P ag e
to
server + ServerAddr.getHostName()
On Port
{ s=remoteIn.readUTF(); Char.recievedText.setText(s); } } catch(IOException e) { System.out.println(e.get message() + :Connection to peer host); } Finally { try { if(remoteIn!=null) remoteIn.class(); } catch(IOException x) } } }
7|P ag e
} } class EXIT implements ActionListener { public void actionPerformed(ActionEvent e) { if(JoptionPane.showConfirmDialog(nw session))==JoptionPane.Yes_OPTION) { JOptionPane.showMessageDialog (new frame(), Thanks, Visit Again ,Good Bye,0); System.exit(0); } } } classTextActionHandler implements ActionListener { public void actionPerformed(ActionEvent e) { try { remoteOut.WriteUTE(Send Text.getText()); sendText.setText( ); } catch(IOException x) } } Private void broadcast (Strings s) { Vector client = Server.getClient(); Data Outputstreamdataout = null for(Enumeration e = clients.elements()); e.hasMoreElements(); { char a; bios com(0, Setting, COM1); Cout<<enter the character to transfer;
9|P ag e
Frame
+Are
you
sure
to
class
a=getch(); bioscom(1,a,COM1); getch(); } RECEIVER # include<iostream.h> # include<conio.h> # include<dos.h> # include<bios.h> # define COM 1 0 # define settings (0*801|0*802|0*001|0*00) Void main() { clrscr(); char a; bioscom(0, setting, com1); b=b*0*00011; a=b; Sleep(3); cout<<a; } } try { if remote out != Null remoteout.close(); if(sock!=Null) Sock.close(); } Catch(IO Exception) { Superfinalize(); } data.out = (DataOutputStream)(e.nextStatement());
10 | P a g e
if(!dataOut.equals(remote out)) { try { data.out.write.if(l); } { Catch(IO Exception.x) { S.O.L.(x.getmessage()+Sailed); Server.Remote from clients(dataOut); } } } } public void clear up() throws IO Exception { if remote out != Null; } if(remote(n!=null) { remoteln=Null; } if(Sock!=null) { Sock.Close(); Sock=Null; } } Protected void Finalize() throws throwable { try { cleanup();
11 | P a g e
} } if(Server sock !=null) { try { serversock.close(); } catch(IOExcetion x) } } } } SERVER SIDE import java.io.*; import java.net.*; importjava.util.Enumeration Public class chatRoom 12m Server { Private int Port = 1003; Private int Port = 1001; Private boolean l = null; } Private vector reciver = new vector(); public static void main (String args[ ]) { SOL(press CTRL to quit); newchatroom {2m Server(), Server} } Void Server( ) { Enum Socket Server sock = Null; Try {
12 | P a g e
SOL(Waiting for+Serveraddr.gethost Name( )+ On PST+post) Server Sock = new Server Socket(Port,50); } Catch(IOException) { system.out.println(i.getmessage( )+ failed) return; } While(i) { try { Socket socket= Server sock.accept( ); SOL (accept+Socket.getnetaddress().get last name) DataOutputStream remote out = new DataOutputStream (Socket.getOutputStream( )); client add element(remote out); newServerHelper(socket remoteout , char); Catch(IOException e) { System.out.println(e.getmessage()+ Sailed); Catch(IOException e) Super finalize( ); } }
13 | P a g e
#define SETTINGS(0x8010x02|0x00|8x00) void main() { chara,s[5]; intI,z=0,x; close_lrstart,end; clrscr(); lrioscam(0,SETTINGS,COM 2); start=close(); k=0; while(s[k-1]=\0) { char=lrioscam(2,0,win 2); char n=1 &0x0011; if(n==\0) {s[x]=n; x++; if un2=A && n<=2) || (n>=0 && n<=z) || (n>=0 && n<=g)) { s[k]=n; k++; end=close(); z=next[(end=start)]|k-[lk]|)+z; i=0; while(i<z && s[i]!=\0){ cout<<s[i]; i++; } if(k<z){ cout<<(\n start<<(z-k)<<token remains); z=z-k; } else z=0; for(i=0;i<=k;i++) { s[i]=0; } goto(1); getch();}
15 | P a g e
p->length=infinity; p->value=null; state[t].length=0; state[t].label=permanens; k=t; do{ for(i=0;i<n;i++) { if list[k][i]!=0 && state[i].label=tentative) { if (state[k].lenght+list[k][i]<state[i].lenght) { state[i].predecessor=k; state[i].length= state[k].length +list[k][i];}}} state[]k.label=1; }while(k!=s); i=0; k=s; do{ push[i]=k; cout<<path[i]+1<< ; k= state[k].predecessor;} }while(k>0);{ void main() { intsource,destt; clrscr(); get_dir(); cout<<\n enter source number:); cin>>source; cout<<enter destination number); cin>>dest; shortest_path(source-1,dest-1); getch(); }
17 | P a g e