b1 lan text and voice chat

25
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopasdfg hjklzxcvbnmqwertyuiopasdfghjklzxc vbnmqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopasdfg hjklzxcvbnmqwertyuiopasdfghjklzxc vbnmqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopasdfg hjklzxcvbnmrtyuiopasdfghjklzxcvbn mqwertyuiopasdfghjklzxcvbnmqwert yuiopasdfghjklzxcvbnmqwertyuiopas dfghjklzxcvbnmqwertyuiopasdfghjklz LAN TEXT AND VOICE CHAT www.BEProjectReport.com VISIT US, CHOOSE THE PROJECT YOU LIKE AND CLICK THE DOWNLOAD BUTTON

Upload: aanchal-arora

Post on 09-Nov-2015

32 views

Category:

Documents


3 download

DESCRIPTION

voice chatting system

TRANSCRIPT

  • qwertyuiopasdfghjklzxcvbnmqwerty

    uiopasdfghjklzxcvbnmqwertyuiopasd

    fghjklzxcvbnmqwertyuiopasdfghjklzx

    cvbnmqwertyuiopasdfghjklzxcvbnmq

    wertyuiopasdfghjklzxcvbnmqwertyui

    opasdfghjklzxcvbnmqwertyuiopasdfg

    hjklzxcvbnmqwertyuiopasdfghjklzxc

    vbnmqwertyuiopasdfghjklzxcvbnmq

    wertyuiopasdfghjklzxcvbnmqwertyui

    opasdfghjklzxcvbnmqwertyuiopasdfg

    hjklzxcvbnmqwertyuiopasdfghjklzxc

    vbnmqwertyuiopasdfghjklzxcvbnmq

    wertyuiopasdfghjklzxcvbnmqwertyui

    opasdfghjklzxcvbnmqwertyuiopasdfg

    hjklzxcvbnmrtyuiopasdfghjklzxcvbn

    mqwertyuiopasdfghjklzxcvbnmqwert

    yuiopasdfghjklzxcvbnmqwertyuiopas

    dfghjklzxcvbnmqwertyuiopasdfghjklz

    LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com

    VISIT US, CHOOSE THE PROJECT YOU LIKE AND CLICK THE DOWNLOAD BUTTON

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 2

    CHAPTER 1

    INTRODUCTION

    A communication is the infrastructure that allows two or more computers (called hosts) to

    communicate with each other. The network achieves this by providing a set of rules for

    communication, called protocols, which should be observed by all participating hosts. The need for a

    protocol should be obvious: it allows different computers from different vendors and with different

    operating characteristics to speak the same language.

    Network is defined as a system in which two or more computer systems are connected

    through various channel or medium. As text and voice communication is one of the most suitable

    forms of communication. LAN Voice and Text Chat is a software application that enables users to

    communicate with each other when connected in a LAN network. This project provides voice and

    text chat for LAN network. This project contains four module i.e login information, text chat, voice

    chat, help Tab. Login Information provides Username and Password to respective LAN user to

    provide confidentiality and authenticity. Text and Voice chat is simply the transmission of text and

    voice data from one computer to another. Help tab provides details about application i.e. how to use

    this application. Much organization provides LAN facility into their buildings. So, this application

    can be use as one type of communication, such as intercom communication and Intranet application.

    1.1 OBJECTIVE OF WORK

    Easier communication:- Application provides text and voice communication, which are

    common communication methods.

    Cheaper communication:- Once you set up LAN for organization you dont need to pay

    extra charge for communication between systems.

    Quick communication:- As conventional speed of LAN is from 1 to 20Mbps.Thus, it

    provides fast communication than any network.

    1.2 SCOPE OF THE WORK

    Organization This application can be use in any organization to transmit information just

    like intercom facility and intranet application

    Education - This application plays vital role in Educational Institute just like conferencing.

    With the help of this application teachers can address student sitting in two different classes

    i.e. voice conference

    Rural Area - As it is one form of offline communication so it is use in those rural area

    where internet facility is unavailable

    Industry Same just like organization we use this in industry as a intranet application.

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 3

    1.3 ORGANISATION OF REPORT

    The report discusses the theoretical and the practical approach, which we have implemented,

    in detail. Chapter 2 discusses literature survey of LAN Voice And Text Chat where approaches and

    methodologies for developing LAN Voice And Text Chat has discussed. Chapter 3 discusses the

    system requirement for project and chapter 4 discusses the practical oriented description of LAN

    Voice and Text Chat in which we are going to specify the project requirements, the technology use

    for the development of project and focuses on technology implementation for accomplishment of our

    project. Finally, Chapter 5 concluded the project.

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 4

    CHAPTER 2

    LITERATURE SURVEY

    2.1 LAN

    A local area network (LAN) is a computer network that interconnects computers in a limited

    area such as a home, school, computer laboratory, or office building. The defining characteristics of

    LAN in contrast to wide area networks (WAN) include their usually higher data-transfer rates,

    smaller geographic area, and lack of a need for leased telecommunication lines. ARCNET, Token

    Ring and other technology standards have been used in the past, but Ethernet over twisted pair

    cabling, and Wi-Fi are the two most common technologies currently used to build LANs.

    Early LAN cabling had always been based on various grades of coaxial cable. However

    shielded twisted pair was used in IBM's Token Ring implementation, and in 1984 StarLAN showed

    the potential of simple unshielded twisted pair by using Cat3the same simple cable used for

    telephone systems. This led to the development of 10Base-T (and its successors) and structured

    cabling which is still the basis of most commercial LANs today. In addition, fiber-optic cabling is

    increasingly used in commercial applications. As cabling is not always possible, wireless Wi-Fi is

    now the most common technology in residential premises cabling required is minimal and it is well

    suited to mobile laptops and smart phones. Network topology describes the layout pattern of

    interconnections between devices and network segments. Switched Ethernet has been for some time

    the most common Data Link Layer and Physical Layer implementation for local area networks. At

    the higher layers, the Internet Protocol (TCP/IP) has become the standard. Smaller LANs generally

    consist of one or more switches linked to each other, often at least one is connected to a router, cable

    modem, or ADSL modem for Internet access.

    Larger LANs are characterized by their use of redundant links with switches using the

    spanning tree protocol to prevent loops, their ability to manage differing traffic types via quality of

    service (QoS), and to segregate traffic with VLANs. Larger LANs also contain a wide variety of

    network devices such as switches, firewalls, routers, load balancers, and sensors. LANs may have

    connections with other LANs via leased lines, leased services, or by tunnelling across the Internet

    using virtual private network technologies. Depending on how the connections are established and

    secured in a LAN, and the distance involved, a LAN may also be classified as a metropolitan area

    network (MAN) or a wide area network (WAN).

    2.1.1 Lan Voice And Text Chat

    The brief definition of LAN VOICE AND TEXT CHAT is to provide the communication

    between the client and server connected in a LAN network. This is achieved by, first installing the

    client side application on the client machine. After installation different kinds of operation are

    performed on the client machine.

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 5

    A simple example: To communicate client with server and how it can be done? We first install client

    side module on client machine and Then user resister from client module. Then client start

    communicating with other clients or the server. This communication takes place with the help of text

    or voice.

    2.2 PROTOCOL USED

    Proposed system demands use of both Transmission Control Protocol (TCP/IP). The listing of

    available servers at the client side is implemented purely based on the concept full duplex property.

    Selection of this protocol for implementing this feature is due to the need for full duplex protocol. It

    provides a connection oriented service for sending packets to data server. TCP is a higher level

    protocol that manages to robustly string together the packets, sorting and retransmitting them as

    necessary to reliably transmit the data.

    2.2.1 TCP

    TCP (Transmission Control Protocol) is a connection based protocol that provides a' reliable

    flow of data between two computers. When two applications want to communicate to each other

    reliably, they connect and send data back and forth over that connection. This is analogous to making

    a telephone call. A connection is established when you dial a phone number listener answers. You

    send data back and forth over the connection by speaking to one another over the phone lines. Like

    the phone company, TCP guarantees that data sent from one end of the connection actually gets to

    the other end and in the same order was sent. Otherwise, an error is reported. TCP provides a point to

    point channel for applications that require reliable communications. The order in which the data is

    sent and received over the network is critical to the success of applications like HTTP, FTP and

    Telnet. When HTTP is used to read from a URL, the data must be received in the order in which it

    was sent. Otherwise, you end up with a jumbled HTML file, a corrupt zip file, or some other invalid

    information.

    2.2.2 Socket

    A Socket is one end point of a two way communication link between two programs running

    on the network. A Socket is bound to a port number so that the TCP layer can identify the application

    that data is destined to be sent. A Socket is one end point of a two way communication link between

    two programs running on the network. Socket classes are used to represent the connection between a

    client program and a server program. Java.net package provides two classes, Socket and Server

    Socket that implement client side of the connection and the server side of the connection,

    respectively.

    Normally, a server runs on a specific computer and has a socket that is bound to a specific

    port number. The server just waits, listening to the socket for a client to make a connection request.

    On the client side: the client knowns the host name of the machine on which server is running and

    the port number to which the server is connected. To make a connection request, the client tries to

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 6

    rendezvous with the server on the server machine and port. Server client N connection request. If

    everything goes well, the server accepts the connection upon acceptance, the server gets a new

    socket bounds to a different port. It needs a new socket (and consequently a different port number) so

    that it can continue to listen to the original socket for connection request while tending to the needs

    of the connected client. On the Client side, if the connection is accepted, a socket is successfully

    created and the client can use the socket to communicate with the server. Note that the socket on the

    client side is not bound to the port number used to rendezvous with the server. Rather, the client is

    assigned a port number local to the machine on which the client is running.

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 7

    CHAPTER 3

    SYSTEM REQUIREMENTS

    3.1 SOFTWARE REQUIREMENT

    Item Purpose

    My SQL Database

    NetBeans IDE GUI interface

    Windows 32 Bit Client

    Microsoft Office 2007 Required for generating reports.

    JDK1.6 Runtime environment

    Table 3.1

    3.2 HARDWARE REQUIREMENT

    Item Purpose

    Intel Pentium 2 onwards 1.96 GHz

    RAM 256 MB

    HDD 80 GB

    Mike Voice Input

    Speaker Voice Output

    Table 3.2

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 8

    3.3 DESCRIPTION OF TECHNOLOGIES

    3.3.1 JAVA

    Java is an object-oriented programming language with a built-in application programming

    interface (API) that can handle graphics and user interfaces and that can be used to create

    applications or applets. Java also has standard libraries for doing mathematics. Much of the syntax of

    Java is the same as C and C++. However, the biggest difference is that we must write object oriented

    code in Java. Procedural pieces of code can only be embedded in objects.

    Features -

    1. Compiler/Interpreter Combination.

    2. Robustness.

    3. Several dangerous features of C & C++ eliminated.

    4. Automatic Memory Management.

    5. Security.

    6. Threading

    3.3.2 SQL

    SQL stands for Structured Query Language. SQL is a standard language for accessing and

    manipulating databases. SQL is an ANSI (American National Standards Institute) standard. SQL can

    execute queries against a database. It can retrieve data from a database, insert, update and delete

    records in a database, create new databases, new tables in a database, stored procedures, views, set

    permissions on tables, procedures, and views, etc.

    3.3.3 RMI

    Remote Method Invocation allows applications to call object methods located remotely,

    sharing resources and processing load across systems. Unlike other systems for remote execution

    \which require that only simple data types or defined structures be passed to and from methods, RMI

    allows any Java object type to be used - even if the client or server has never encountered it before.

    RMI allows both client and server to dynamically load new object types as required.

    3.3.4 Beans

    JavaBeans are reusable software components for Java that can be manipulated visually in a

    builder tool. Practically, they are classes written in the Java programming language conforming to a

    particular convention. They are used to encapsulate many objects into a single object (the bean), so

    that they can be passed around as a single bean object instead of as multiple individual objects. A

    Java Bean is a Java Object that is serializable, has a nullify constructor, and allows access to

    properties using getter.

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 9

    3.3.5 Java Development Kit (JDK)

    The Java Development Kit (JDK) is a Sun product aimed at Java developers. Since the

    introduction of Java, it has been by far the most widely used Java SDK. On 17 November, 2006, it

    was released under the GNU General Public License (GPL). Each new version of the JDK brings

    with it new functionality. The changes included in each new version of a JDK are documented in a

    file called Changes that is associated with each new JDK release. The functionality provided by

    JDKs resides in classes. These classes can then be used in application programs. A problem,

    however, arises when a program that relies on new functionality is executed on a platform where the

    JDK does not include the new classes. Clearly, if the classes do not exist in

    the JDK, the application program cannot use them, and a "Class not found exception may occur. In

    such a case, the developer should handle the error and gracefully inform the user. Downward

    compatibility in Java should always be tested, not assumed.

    The primary components of the JDK are a selection of programming tools, including:

    javac - The compiler, which converts source code into Java byte code.

    jar - The achiever, which packages related class libraries into a single JAR file.

    Javadoc The documentation Generator, which automatically generates

    documentation from source code comments.

    jdb - The debugger.

    The JDK also comes with a complete Java Runtime Environment, usually called a private runtime. It

    consists of a Java Virtual Machine and all of the class libraries that will be present in the production

    environment, as well as additional libraries only useful to developers, such as the internationalization

    libraries and the IDL libraries.

    3.2.6 Netbeans

    The NetBeans IDE Bundle for Java ME is a tool for developing applications that run on

    mobile devices; generally mobile phones, but this also includes entry-level PDAs and Java Card,

    among others.

    The NetBeans IDE comes bundled with the latest Java ME SDK 3.0 which supports both CLDC and

    CDC development. One can easily integrate third-party emulators for a robust testing environment.

    You can download other Java platforms, including the Java Card Platform 3.0, and register them in

    the IDE.

    NetBeans refers to both a platform framework for Java desktop applications, and an

    integrated development environment (IDE) for developing with Java, JavaScript, PHP, Python (no

    longer supported after NetBeans 7), Groovy, C, C++, Scala, Clojure, and others. The NetBeans IDE

    7.0 no longer supports Ruby and Ruby on Rails, but a third party has begun work on a separate plug-

    in.

    The NetBeans IDE is written in Java and can run on Windows, Mac OS, Linux, Solaris and

    other platforms supporting a compatible JVM. A pre-existing JVM or a JDK is not required. The

    NetBeans platform allows applications to be developed from a set of modular software components

    called modules. Applications based on the NetBeans platform (including the NetBeans IDE) can be

    extended by third party developers.

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 10

    CHAPTER 4

    IMPLEMENTATION

    4.1 OVERVIEW

    This chapter provides theoretical information about various technologies and languages used to

    design this project. With the help of this tool, we can check how we monitor the network.

    4.2 DATA FLOW DIAGRAM

    This technique uses graphical tools called data flow diagrams to depict the information flow

    through the system and the transformation that are applied to between the input and output stages.

    A DFD may be used to represent a system or software at any level of abstraction the lowest

    level of abstraction is presented by a source code. DFD may be partitioned into levels that represent

    increasing information flow and functional details.

    Figure 4.1 Data Flow Diagram

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 11

    In above figure double square shows the Entity, rectangle with rounded corners is used to

    show the occurrence of transforming process, arrow shows movement of data from one point to

    another point and last symbol used in data flow diagram is an open ended rectangle which represents

    a data store.

    Above figure shows data flow diagram for LAN Chat project .In this diagram user1 request to

    user2 for connection. User2 wait for connection request and if user2 accept request then

    communication between user1 and user2 takes place.

    4.3 PROJECT DESIGN

    Figure 4.2 Project Overview

    Figure 4.3 Login Page

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 12

    In the figure 4.3 we have described Login Page of our Project. Every Chat application requires

    user identification to distinguish users and to know to with whom our chat is going on. To provide

    security to user profile, we provided Password utility with each user. Actually, user here denotes

    USERNAME for carry out chat. Then, next field specifies IP address of the remote system to

    which you want to connect. Next field Your IP specifies your own IP address belongs to system on

    LAN. Your IP is evaluated and printed on Login Page automatically using Network Programming

    concepts. And you have to set or type manually IP address of remote machine to which you want to

    connect.

    Figure 4.4 Working Environment of Chat application

    Given figure 4.4 depicts how actually chat is going on between users. The Left-Top side has

    Text Area field notifies the details of text chat that is going on. It shows what actually other user and

    you have typed during Text chat. Below the Text Area field you have given one Text field along

    with Send option. When user writes some text in the Text field and clicks on Send button, the text

    in the Text field button is transmitted to another user which is connected in LAN. The right side area

    specifies status of user whether it is connected to another remote machine or not along with your IP

    address. Below which there is clear chat button which clears all the Text Area fields. Connect

    button connects remote system when user clicks on that button. Save chat history button saves your

    chat session which contains texts. Read History button allows you to view chat sessions.

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 13

    Figure 4.5 Developers Page

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 14

    4.4 PROJECT CODE

    4.4.1 Text Chat

    Client side code:

    import java.net.*;

    import java.io.*;

    class tcpchatclient

    {

    public static void main(String args[])

    {

    Socket s;

    BufferedReader fromsoc,fromkbd;

    PrintStream tosoc;

    String line;

    String ip=args[0];

    try

    {

    s=new Socket(ip,6000);

    fromsoc=newBufferedReader(new InputStreamReader(s.getInputStream()));

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

    tosoc=new PrintStream(s.getOutputStream());

    do

    {

    System.out.println("enter text");

    line=fromkbd.readLine();

    tosoc.println(line);

    line=fromsoc.readLine();

    System.out.println("from server : "+ line);

    }while(!line.equals("exit"));

    }

    catch(Exception e)

    {

    System.out.println(e);

    }

    }

    }

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 15

    Server side code:

    import java.net.*;

    import java.io.*;

    class tcpchatserver

    {

    public static void main(String args[])

    {

    ServerSocket server;

    Socket s;

    BufferedReader fromsoc,fromkbd;

    PrintStream tosoc;

    String line;

    try

    {

    server=new ServerSocket(6000);

    System.out.println("server waiting");

    s=server.accept();

    System.out.println("connected");

    fromsoc=new BufferedReader(newInputStreamReader(s.getInputStream()));

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

    tosoc=new PrintStream(s.getOutputStream());

    do

    {

    line=fromsoc.readLine();

    System.out.println("from client : "+ line);

    System.out.println("enter text");

    line=fromkbd.readLine();

    tosoc.println(line);

    }while(!line.equals("exit"));

    }

    catch(Exception e)

    {

    System.out.println(e);

    }

    }

    }

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 16

    4.4.2 Voice Chat

    Client side code:

    import java.io.*;

    import java.net.*;

    import javax.sound.sampled.*;

    public class LVC1

    {

    ServerSocket MyService;

    Socket clientSocket = null;

    BufferedInputStream input;

    TargetDataLine targetDataLine;

    BufferedOutputStream out;

    ByteArrayOutputStream byteArrayOutputStream;

    AudioFormat audioFormat;

    SourceDataLine sourceDataLine;

    byte tempBuffer[] = new byte[10000];

    LVC1() throws LineUnavailableException

    {

    try

    {

    audioFormat = getAudioFormat();

    DataLine.Info dataLineInfo = new DataLine.Info(SourceDataLine.class, audioFormat);

    sourceDataLine = (SourceDataLine) AudioSystem.getLine(dataLineInfo);

    sourceDataLine.open(audioFormat);

    sourceDataLine.start();

    MyService = new ServerSocket(1987);

    clientSocket = MyService.accept();

    System.out.println("Accepted");

    ScaptureAudio();

    input = new BufferedInputStream(clientSocket.getInputStream());

    out = new BufferedOutputStream(clientSocket.getOutputStream());

    while(input.read(tempBuffer)!=-1)

    {

    sourceDataLine.write(tempBuffer,0,10000);

    }

    }

    catch (IOException e)

    {

    e.printStackTrace();

    }

    }

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 17

    private AudioFormat getAudioFormat()

    {

    float sampleRate = 8000.0F;

    int sampleSizeInBits = 16;

    int channels = 1;

    boolean signed = true;

    boolean bigEndian = false;

    return new AudioFormat(sampleRate, sampleSizeInBits, channels, signed, bigEndian);

    }

    public static void main(String s[]) throws LineUnavailableException

    {

    LVC1 lvc1=new LVC1();

    }

    private void ScaptureAudio()

    {

    try

    {

    Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();

    audioFormat = getAudioFormat();

    DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class, audioFormat);

    Mixer mixer = AudioSystem.getMixer(mixerInfo[3]);

    targetDataLine = (TargetDataLine) mixer.getLine(dataLineInfo);

    targetDataLine.open(audioFormat);

    targetDataLine.start();

    Thread ScaptureThread = new SCaptureThread();

    ScaptureThread.start();

    }

    catch (Exception e)

    {

    System.out.println(e);

    System.exit(0);

    }

    }

    class SCaptureThread extends Thread

    {

    byte tempBuffer[] = new byte[10000];

    public void run()

    {

    try

    {

    while (true)

    {

    int cnt = targetDataLine.read(tempBuffer, 0, tempBuffer.length);

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 18

    out.write(tempBuffer);

    }

    }

    catch (Exception e)

    {

    System.out.println(e);

    System.exit(0);

    }

    }

    }

    }

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 19

    Server side code:

    import java.io.*;

    import java.net.*;

    import javax.sound.sampled.*;

    public class LVC2

    {

    boolean stopCapture = false;

    ByteArrayOutputStream byteArrayOutputStream;

    AudioFormat audioFormat;

    TargetDataLine targetDataLine;

    AudioInputStream audioInputStream;

    BufferedOutputStream out = null;

    BufferedInputStream in = null;

    Socket sock = null;

    SourceDataLine sourceDataLine;

    public static void main(String[] args)

    {

    LVC2 lvcc = new LVC2();

    lvcc.captureAudio(args[0]);

    }

    private void captureAudio(String s)

    {

    try

    {

    sock = new Socket(s, 1987);

    out = new BufferedOutputStream(sock.getOutputStream());

    in = new BufferedInputStream(sock.getInputStream());

    Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();

    audioFormat = getAudioFormat();

    DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class, audioFormat);

    Mixer mixer = AudioSystem.getMixer(mixerInfo[3]);

    targetDataLine = (TargetDataLine) mixer.getLine(dataLineInfo);

    targetDataLine.open(audioFormat);

    targetDataLine.start();

    Thread captureThread = new CaptureThread();

    captureThread.start();

    DataLine.Info dataLineInfo1 = new DataLine.Info(SourceDataLine.class, audioFormat);

    sourceDataLine= (SourceDataLine) AudioSystem.getLine(dataLineInfo1);

    sourceDataLine.open(audioFormat);

    sourceDataLine.start();

    Thread playThread = new PlayThread();

    playThread.start();

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 20

    }

    catch (Exception e)

    {

    System.out.println(e);

    System.exit(0);

    }

    }

    class CaptureThread extends Thread

    {

    byte tempBuffer[] = new byte[10000];

    public void run()

    {

    byteArrayOutputStream = new ByteArrayOutputStream();

    stopCapture = false;

    try

    {

    while (!stopCapture)

    {

    int cnt = targetDataLine.read(tempBuffer, 0, tempBuffer.length);

    out.write(tempBuffer);

    if (cnt > 0)

    {

    byteArrayOutputStream.write(tempBuffer, 0, cnt);

    }

    }

    byteArrayOutputStream.close();

    }

    catch (Exception e)

    {

    System.out.println(e);

    System.exit(0);

    }

    }

    }

    private AudioFormat getAudioFormat()

    {

    float sampleRate = 8000.0F;

    int sampleSizeInBits = 16;

    int channels = 1;

    boolean signed = true;

    boolean bigEndian = false;

    return new AudioFormat(sampleRate, sampleSizeInBits, channels, signed, bigEndian);

    }

    class PlayThread extends Thread

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 21

    {

    byte tempBuffer[] = new byte[10000];

    public void run()

    {

    try

    {

    while (in.read(tempBuffer) != -1)

    {

    sourceDataLine.write(tempBuffer, 0, 10000);

    }

    }

    catch (IOException e)

    {

    e.printStackTrace();

    }

    }

    }

    }

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 22

    4.4.3 Data Streams

    Data streams support binary I/O of primitive data type values (boolean, char, byte, short, int,

    long, float, and double) as well as String values. All data streams implement either the DataInput

    interface or the DataOutput interface. This section focuses on the most widely-used implementations

    of these interfaces, DataInputStream and DataOutputStream.

    The DataStreams example demonstrates data streams by writing out a set of data records, and

    then reading them in again. Each record consists of three values related to an item on an invoice, as

    shown in the following table:

    Table 4.3 Data stream

    4.4.4 Byte Stream

    Programs use byte streams to perform input and output of 8-bit bytes. All byte stream classes

    are descended from InputStream and OutputStream.

    There are many byte stream classes. To demonstrate how byte streams work, we'll focus on the file

    I/O byte streams, FileInputStream and FileOutputStream. Other kinds of byte streams are used in

    much the same way; they differ mainly in the way they are constructed.

    4.4.5 Buffered Streams

    Most of the examples we've seen so far use unbuffered I/O. This means each read or writes

    request is handled directly by the underlying OS. This can make a program much less efficient, since

    each such request often triggers disk access, network activity, or some other operation that is

    relatively expensive.

    To reduce this kind of overhead, the Java platform implements buffered I/O streams.

    Buffered input streams read data from a memory area known as a buffer; the native input API is

    called only when the buffer is empty. Similarly, buffered output streams write data to a buffer, and

    the native output API is called only when the buffer is full.

    A program can convert an unbuffered stream into a buffered stream using the wrapping idiom

    we've used several times now, where the unbuffered stream object is passed to the constructor for a

    buffered stream class. Here's how you might modify the constructor invocations in the

    CopyCharacters example to use buffered I/O:

    inputStream = new BufferedReader(new FileReader("xanadu.txt"));

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 23

    outputStream = new BufferedWriter(new FileWriter("characteroutput.txt"));

    There are four buffered stream classes used to wrap unbuffered streams:

    BufferedInputStream and BufferedOutputStream create buffered byte streams, while BufferedReader

    and BufferedWriter create buffered character streams.

    4.4.6 Flushing Buffered Streams

    It often makes sense to write out a buffer at critical points, without waiting for it to fill. This

    is known as flushing the buffer.

    Some buffered output classes support autoflush, specified by an optional constructor

    argument. When autoflush is enabled, certain key events cause the buffer to be flushed. For example,

    an autoflush PrintWriter object flushes the buffer on every invocation of println or format. See

    Formatting for more on these methods. To flush a stream manually, invoke its flush method. The

    flush method is valid on any output stream, but has no effect unless the stream is buffered.

    4.4.7 Class Summary

    AudioFileFormat : An instance of the AudioFileFormat class describes an audio file,

    including the file type, the file's length in bytes, the length in sample frames of the audio data

    contained in the file, and the format of the audio data.

    AudioInputStream : An audio input stream is an input stream with a specified audio format

    and length.

    public class ServerSocket extends Object : This class implements server sockets. A server

    socket waits for requests to come in over the network. It performs some operation based on that

    request, and then possibly returns a result to the requester. The actual work of the server socket is

    performed by an instance of the SocketImpl class. An application can change the socket factory that

    creates the socket implementation to configure itself to create sockets appropriate to the local

    firewall.

    public class Socket extends Object : This class implements client sockets (also called just

    "sockets"). A socket is an endpoint for communication between two machines. The actual work of

    the socket is performed by an instance of the SocketImpl class. An application, by changing the

    socket factory that creates the socket implementation, can configure itself to create sockets

    appropriate to the local firewall.

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 24

    CHAPTER 5

    CONCLUSION

    5.1 OBJECTIVE

    For providing efficient way of communication between the two or more systems that are

    connected across LAN networks, this application is helpful.

    5.2 CONCLUSION

    Thus we have got aim of our project is to provide user friendly project about the LAN Chat

    concept, for user across LAN which maintain their chat history.

    This project efficiently fulfils the communication facility with security by means of password

    for every user who has registered with this application.

    5.3 FUTURE SCOPE

    Extensibility

    This application is extendable in such a way that its original may not expect. We can also

    shares and transmit the files between LAN users. With this, you can represent voice communication

    in a graphical manner with voice intensities. You can add emoticons in text chat.

  • LAN TEXT AND VOICE CHAT

    www.BEProjectReport.com Page 25

    BIBLIOGRAPHY

    The Complete Reference JAVA J2SE 5th edition, by Herbert Schildt

    Java Cookbook (e-book)

    Java How To Program 6th Edition, by Deiten

    Java in 60 Minutes a Day, by Richard F. Raposa