Sei sulla pagina 1di 23

CHAT MESSANGER

//coding import java.net.*; import java.io.*; import java.util.*; import java.awt.*; class chatClient extends Frame implements Runnable { Socket soc; TextField tf; TextArea ta; Button btnSend,btnClose; String sendTo; String LoginName; Thread t=null; DataOutputStream dout; DataInputStream din; chatClient(String LoginName,String chatwith) throws Exception { super(LoginName); this.LoginName=LoginName; sendTo=chatwith; tf=new TextField(50); ta=new TextArea(50,50); btnSend=new Button("Send"); btnClose=new Button("Close"); soc=new Socket("127.0.0.1",5217); din=new DataInputStream(soc.getInputStream()); dout=new DataOutputStream(soc.getOutputStream()); dout.writeUTF(LoginName);

t=new Thread(this); t.start(); } void setup() { setSize(600,400); setLayout(new GridLayout(2,1)); add(ta); Panel p=new Panel(); p.add(tf); p.add(btnSend); p.add(btnClose); add(p); show(); } public boolean action(Event e,Object o) { if(e.arg.equals("Send")) { try { dout.writeUTF(sendTo + " " + "DATA" + " " + tf.getText().toString()); ta.append("\n" + LoginName + " Says:" + tf.getText().toString()); tf.setText(""); } catch(Exception ex) { }

} else if(e.arg.equals("Close")) { try { dout.writeUTF(LoginName + " LOGOUT"); System.exit(1); } catch(Exception ex) { } } return super.action(e,o); } public static void main(String args[]) throws Exception { chatClient Client1=new chatClient(args[0],args[1]); Client1.setup(); } public void run() { while(true) { try { ta.append( "\n" + sendTo + " Says :" + din.readUTF()); } catch(Exception ex) { ex.printStackTrace(); }

} } }

//Chat Server import java.net.*; import java.util.*; import java.io.*; class chatServer { static Vector ClientSockets; static Vector LoginNames; chatServer() throws Exception { ServerSocket soc=new ServerSocket(5217); ClientSockets=new Vector(); LoginNames=new Vector(); while(true) { Socket CSoc=soc.accept(); AcceptClient obClient=new AcceptClient(CSoc); } { chatServer ob=new chatServer(); } class AcceptClient extends Thread { Socket ClientSocket; DataInputStream din; DataOutputStream dout; AcceptClient (Socket CSoc) throws Exception {

ClientSocket=CSoc; din=new DataInputStream(ClientSocket.getInputStream()); dout=new DataOutputStream(ClientSocket.getOutputStream()); String LoginName=din.readUTF(); System.out.println("User Logged In :" + LoginName); LoginNames.add(LoginName); ClientSockets.add(ClientSocket); start(); } public void run() { while(true) { try { String msgFromClient=new String(); msgFromClient=din.readUTF(); StringTokenizer st=new StringTokenizer(msgFromClient); String Sendto=st.nextToken(); String MsgType=st.nextToken(); int iCount=0; if(MsgType.equals("LOGOUT")) { for(iCount=0;iCount<LoginNames.size();iCount++) { if(LoginNames.elementAt(iCount).equals(Sendto)) {

msg=msg+" " +st.nextToken(); } for(iCount=0;iCount<LoginNames.size();iCount++) { LoginNames.removeElementAt(iCount); ClientSockets.removeElementAt(iCount); System.out.println("User " + Sendto +" Logged Out ..."); break; } } } else { String msg=""; while(st.hasMoreTokens()) { if(LoginNames.elementAt(iCount).equals(Sendto)) { Socket tSoc=(Socket)ClientSockets.elementAt(iCount); DataOutputStream tdout=new DataOutputStream(tSoc.getOutputStream()); tdout.writeUTF(msg); break; } } if(iCount==LoginNames.size()) { dout.writeUTF("I am offline"); } else {

} } if(MsgType.equals("LOGOUT")) { break; } } catch(Exception ex) { ex.printStackTrace(); }

} } } }

WORLD COLLEGE OF TECHNOLOGY & MANAGEMENT GURGAON-110058 Batch (2008-2012)

SUMMER TRAINING REPORT ON CHAT MESSANGER Submitted in partial fulfillment of the requirements for the award of the degree of B.Tech to Maharishi Dayanand University, Rohtak

Guide: Mr. RITESH

Submitted by: Dipti Singh 19/I.T/08

ACKNOWLEDGEMENT

Project work is essentially a learning process in which apart from learning the subject itself, one also learns to share ideas and work as a team. I am sure that involvement in this project as well as the exposure I have gained will prove to be stepping stone for other opportunities that come in my way I am thankful to my project guide Mr. ritesh who helped in all ways to make this project a success. Last but not least I am thankful to all those people who have directly or indirectly contributed for the success of this project.

Dipti singh

INDEX
S.No. Topics Teacher s Signatur e

1. 2. 3.

About BHEL Certificate About JAVA CORE INTRODUCTION FEATURES BASIC JAVA PROGRAM CONNECTIVITY About Project Introduction Software used Coding conclusion

CORE JAVA
INTRODUCTION
In 1990, Sun Microsystem began a project called GREEN to develop software for consumer electronics. It took 18 months to develop the first working version. This language initially called Oak, but was renamed to Java in 1995. Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank and Mike Sheridan. In 1991 Gosling began writing software in C++ for embedding into such items as toasters, VCRs etc. The embedded software makes appliances more intelligent, typically by adding Digital display or by using Artificial Intelligence to better control mechanism. However, it soon become apparent to Gosling that C++ was wrong tool for the job. C++ is flexible enough to control embedded systems, but it is susceptible to bugs that can crash system. In particular, C++ uses direct references to system resources and requires programmer to keep track of how these resources are managed, which is significant burden on programmers. This burden of resource management is a barrier to writing reliable, portable software and it is serious problem for consumer electronics.

FEATURES
Simple: A JAVA programmer need not know the internal of java. Object-oriented: Java defines data as object with method that supports the objectoriented. Java is purely objectoriented. Any codes you write, you have to write in Class. Distributed: Java programs can access data across the web as easily as they access data from a local system. Interpreted and Compiled: Java is both interpreted and compiled. A java applet is written and compiled into what is called bytecode. This byte code is binary and platform independent. When this applet has to be executed it is fetched to the local system where it is interpreted by the browser. Only 80% is compiled and 20% interpreted when executed, this is because security purpose. Java environment contains an element called the linker. The linker checks the coming data into your machine to make sure it does not contain deliberately harmful files or files that could disrupt the functioning your computer. Architecture Natural: Java can work with a variety of hardware and operating system. The only requirement

is that the system should have java enabled Internet browser. Robust: Robust means reliable. A reliable language will allow you to write programs that dont crash when least expected and will also be bug free. Java is secure: A program traveling across the Internet onto your machine is unseen by you and could possibly be carrying a virus along with it. This is a possibility in java program. But due to strong type checking done by java on the users local machine, any changes to the program are tagged as an error the program will not executed. Multithreaded: Ability of an applet to perform multiple tasks at the same time. For e.g.; suppose you are playing a game one thread displaying score, one graphics. In single threaded applet only one task can be performed at a given point of time. Dynamic: A java program can consist of many modules that are written by many programmers. These modules may undergo many changes. Java makes interconnection between modules at run time, which easily avoids the problem caused by the changes of the code used by your program java thus dynamic.

BASIC JAVA PROGRAM


//Java Program public class MyFirstProg { public static void main(String args[]) { System.out.println(This is first program); } } Let us check it line by line: Line 1: This line is called comment line, which will be ignored by the compiler. They make program more readable. The multiple line comment begins with /*and ends with*/. A single line comment begins with a // and ends at the end of the line. Line 2: In java everything should be in class which is declared using the keyword class. public means your class is available and accessible by any one. MyFirstProg is the name of the class. Line 4: The public keyword is an access specifier, which controls the visibility and scope of class members. The static keyword allows the main() method to be called, without needing to create an instance of the class. The void keyword tells the compiler that the main() method does not return any value when it is executed.

Main() is the entry point of your program i.e; programs execution starts from here. String is a type which stores character strings and args[] is an array of type String. Line 6:System.out.println is used to print anything on the console. {} defines the scope of any method / class ; line terminator

Saving File: Primary name of file must be same as the name of the class and extension must be java.

Compilation: javac MyFirstProg.java After compilation it creates .class file which is bytecode format

Execution: java MyFirstProg

CONNECTIVITY
Connectivity is connecting FRONT END with BACK END. Database Management: A database is a collection of related information. A DBMS is a software that provide us a mechanism to retrieve, modify and add data to the database. Examples are :MS-Access, MS SQL Server, Oracle, Sybase, Informix and Ingress. Each DBMS/RDMS store the data in their own format. MS Access stores in .mdb file format and MS SQL stores data in a .dat file format. Using connectivity one can develop a application through which user can interact with database like user can add/retrieve/modify/delete data through that application.

ODBC: Is an abbreviation of Open Database Connectivity .It is a interface used to interact with database from programming language through its functions. It manages this by inserting a middle layer called driver, between the application and the DBMS. It translates queries of application into commands that the DBMS understands. For both the application and the DBMS must be compliant. JDBC:

It provides a database programming for JAVA programs. Since ODBC is an C interfacel thus JAVA program cannot directly communicate with ODBC driver. JavaSoft created the JDBC-ODBC Bridge driver that translate JDBC API to the ODBC API. Steps for Database Access: Import the java.sql package: import java.sql.*; Load and register the driver: Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); Create a Connection object: Connection c=DriverManager,getConnection(jdbc:odbc:DSN); Create a Statement object: Statement s=c.createStatement(); Execute the statement: ResultSet r=s.executeQuery(select * from table); Terminate connection: c.close();

Introduction
NIIT is a leading Global Talent Development Corporation, building skilled manpower pool for global industry requirements. The company which was set up in 1981, to help the nascent IT industry overcome its human resource challenges, has today grown to be amongst worlds leading talent development companies offering learning solutions to Individuals, Enterprises and Institutions across 40 countries. NIITs training solutions in IT, Business Process Outsourcing, Banking, Finance and Insurance, Executive Management Education, and Communication and Professional Life Skills, touch five million learners every year. NIITs expertise in learning content development, training delivery and education process management make it the most preferred training partner, worldwide.

Research-based Innovation, a key driver at NIIT, has enabled the organisation to develop programs and curricula that use cutting-edge instructional design methodologies and training delivery. NIITs Individual Learning Business offerings include industry-endorsed programs for students seeking careers in IT New Age GNIIT (Indias First Cloud Campus), Edgeineers and Global Net Plus for IT professionals. NIIT has provided computer-based learning to over 15,000 government and private schools. The futuristic NIIT NGuru range for schools is a holistic education package that comprises Interactive Classrooms (an embedded

Teaching Learning Material, that uses elements of interactivity, automation and web links library); Math lab (technology tools that enable school students to learn and explore mathematical concepts); IT Wizard (equips the students with core computer knowledge and IT skills); Quick School (an Education Resource Planning solution for school management); and Mobile Science Lab (the first of its kind portable computerized Science Laboratory which enables students to correlate scientific concepts taught in the class to real life). To address the vast population of underserved, school-aged children, NIIT launched the Hole-in-the-Wall education initiative. Its achievements in the area of Minimally Invasive Education earned NIIT the coveted Digital Opportunity Award, by the World Information Technology Services Alliance (WITSA) in 2008. For working professionals, NIIT Imperia, Centre for Advanced Learning, offers Executive Management Education Programs in association with IIM Ahmadabad, IIM Calcutta, IIM Lucknow, IMT Ghaziabad and IIFT Delhi. NIIT Imperia also offers specialized courses in Finance in association with KPMG and on Digital Marketing with Google India and Internet and Mobile Association of India (IAMAI). NIIT Institute of Finance Banking & Insurance (IFBI), formed by NIIT with equity participation from ICICI Bank, offers programs for individuals and corporates in Banking, Financial Services and Insurance. NIIT Uniqua, Centre for Process Excellence, addresses the increasing demand for skilled workers in the business and technology services industry by providing training programs in relevant areas. This is a part of NIIT Institute of Process Excellence, a NIIT-Genpact venture. NIIT Careers@Campus, the companys Institutional Alliances Business for colleges and Universities, delivers in-campus training through Synchronous Learning Technology. NIITs Corporate Learning Solutions, NIITs Corporate Learning Solutions, offers integrated learning solutions (including strategic consulting, learning design, content development, delivery, technology, assessment and learning

management) to Fortune 500 companies, Universities, Technology companies, Training corporations and Publishing houses. NIIT delivers a tailored combination of catalog learning products, technology and services through Element K offerings. These include: vLab: hands-on labs, instructor-led courseware, comprehensive e-reference libraries, technical journals, and KnowledgeHub: hosted learning management platform. This makes NIIT the first and the best choice for comprehensive learning solutions, worldwide. NIITs innovative HR practices have been felicitated by Aon Hewitt as amongst Top 25 Best Employers in India- 2011; Indian Education Awards 2011 as Best Education Company to Work with; by Great Places to Work Institute as amongst Top 25 Indias Best Companies to Work for and First in Training & Education Industry, 2011. Ushering in a new model in higher education is the not-for-profit NIIT University, established in 2009 with a vision of being the leading centre of innovation and learning in emerging areas of the Knowledge Society. Nestled in the foothills of Aravali, in Neemrana, Rajasthan, the picturesque 100 acres fully residential green campus has been developed as an institute of excellence based on the four core principles of providing industry linked, technology based, research driven, seamless education

Potrebbero piacerti anche