JAVA NETWORKING basics for Projects

Hi,
All CE's .
Now a days most of the research is going in Networking field.. because Network is an vast field where we can find number of real time problems and also we can give our own solutions.
So. i m interested in Networking field... so in the same time if any one wants to develop a Software tools for Networking JAVA is the best Language..
Let.us start at Discussion with this Basics of JAVANETWORKING

What You May Already Know About Networking in Java ๐Ÿ˜• ๐Ÿ˜• ๐Ÿ˜•

The word networking strikes fear in the hearts of many programmers. Fear not! Using the networking capabilities provided in the Java environment is quite easy. In fact, you may be using the network already without even realizing it!

Networking Basics:
Computers running on the Internet communicate to each other using either the Transmission Control Protocol (TCP) or the User Datagram Protocol (UDP), as this diagram illustrates: [โ€‹IMG] When you write Java programs that communicate over the network, you are programming at the application layer. Typically, you don't need to concern yourself with the TCP and UDP layers. Instead, you can use the classes in the java.net package. These classes provide system-independent network communication. However, to decide which Java classes your programs should use, you do need to understand how TCP and UDP differ.

TCP

Definition: 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 establish a connection and send data back and forth over that connection. This is analogous to making a telephone call. If you want to speak to Aunt Beatrice in Kentucky, a connection is established when you dial her phone number and she 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 it was sent. Otherwise, an error is reported.
TCP provides a point-to-point channel for applications that require reliable communications. The Hypertext Transfer Protocol (HTTP), File Transfer Protocol (FTP), and Telnet are all examples of applications that require a reliable communication channel. The order in which the data is sent and received over the network is critical to the success of these applications. 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.


UDP

Definition: UDP (User Datagram Protocol) is a protocol that sends independent packets of data, called datagrams, from one computer to another with no guarantees about arrival. UDP is not connection-based like TCP.

The UDP protocol provides for communication that is not guaranteed between two applications on the network. UDP is not connection-based like TCP. Rather, it sends independent packets of data, called datagrams, from one application to another. Sending datagrams is much like sending a letter through the postal service: The order of delivery is not important and is not guaranteed, and each message is independent of any other.
For many applications, the guarantee of reliability is critical to the success of the transfer of information from one end of the connection to the other. However, other forms of communication don't require such strict standards. In fact, they may be slowed down by the extra overhead or the reliable connection may invalidate the service altogether.
Consider, for example, a clock server that sends the current time to its client when requested to do so. If the client misses a packet, it doesn't really make sense to resend it because the time will be incorrect when the client receives it on the second try. If the client makes two requests and receives packets from the server out of order, it doesn't really matter because the client can figure out that the packets are out of order and make another request. The reliability of TCP is unnecessary in this instance because it causes performance degradation and may hinder the usefulness of the service.
Another example of a service that doesn't need the guarantee of a reliable channel is the ping command. The purpose of the ping command is to test the communication between two programs over the network. In fact, ping needs to know about dropped or out-of-order packets to determine how good or bad the connection is. A reliable channel would invalidate this service altogether.
The UDP protocol provides for communication that is not guaranteed between two applications on the network. UDP is not connection-based like TCP. Rather, it sends independent packets of data from one application to another. Sending datagrams is much like sending a letter through the mail service: The order of delivery is not important and is not guaranteed, and each message is independent of any others.




โ€‹

Replies

  • madhumurundi
    madhumurundi
    Re: JAVA NETWORKING basics for Projects..contd...

    Understanding Ports:

    Definition: The TCP and UDP protocols use ports to map incoming data to a particular process running on a computer.

    Generally speaking, a computer has a single physical connection to the network. All data destined for a particular computer arrives through that connection. However, the data may be intended for different applications running on the computer. So how does the computer know to which application to forward the data? Through the use of ports. Data transmitted over the Internet is accompanied by addressing information that identifies the computer and the port for which it is destined. The computer is identified by its 32-bit IP address, which IP uses to deliver data to the right computer on the network. Ports are identified by a 16-bit number, which TCP and UDP use to deliver the data to the right application.
    In connection-based communication such as TCP, a server application binds a socket to a specific port number. This has the effect of registering the server with the system to receive all data destined for that port. A client can then rendezvous with the server at the server's port, as illustrated here:
    [โ€‹IMG]


    In datagram-based communication such as UDP, the datagram packet contains the port number of its destination and UDP routes the packet to the appropriate application, as illustrated in this figure:
    [โ€‹IMG]
    Port numbers range from 0 to 65,535 because ports are represented by 16-bit numbers. The port numbers ranging from 0 - 1023 are restricted; they are reserved for use by well-known services such as HTTP and FTP and other system services. These ports are called well-known ports. Your applications should not attempt to bind to them. โ€‹
  • madhumurundi
    madhumurundi
    Re: JAVA NETWORKING basics for Projects..contd..

    Networking Classes in the JDK:

    Through the classes in java.net, Java programs can use TCP or UDP to communicate over the Internet. The URL, URLConnection, Socket, and ServerSocket classes all use TCP to communicate over the network. The DatagramPacket, DatagramSocket, and MulticastSocket classes are for use with UDP.


    Working with URLs:

    URL is the acronym for Uniform Resource Locator. It is a reference (an address) to a resource on the Internet. You provide URLs to your favorite Web browser so that it can locate files on the Internet in the same way that you provide addresses on letters so that the post office can locate your correspondents. Java programs that interact with the Internet also may use URLs to find the resources on the Internet they wish to access. Java programs can use a class called #-Link-Snipped-# in the java.net package to represent a URL address.



    #-Link-Snipped-#

    A URL takes the form of a string that describes how to find a resource on the Internet. URLs have two main components: the protocol needed to access the resource and the location of the resource. โ€‹
    #-Link-Snipped-#

    Within your Java programs, you can create a URL object that represents a URL address. The URL object always refers to an absolute URL but can be constructed from an absolute URL, a relative URL, or from URL components. โ€‹
    #-Link-Snipped-#

    Gone are the days of parsing a URL to find out the host name, filename, and other information. With a valid URL object you can call any of its accessor methods to get all of that information from the URL without doing any string parsing! โ€‹
    #-Link-Snipped-#

    This section shows how your Java programs can read from a URL using the openStream() method. โ€‹
    #-Link-Snipped-#

    If you want to do more than just read from a URL, you can connect to it by calling openConnection() on the URL. The openConnection() method returns a URLConnection object that you can use for more general communications with the URL, such as reading from it, writing to it, or querying it for content and other information. โ€‹
    #-Link-Snipped-#

    Some URLs, such as many that are connected to cgi-bin scripts, allow you to (or even require you to) write information to the URL. For example, a search script may require detailed query data to be written to the URL before the search can be performed. This section shows you how to write to a URL and how to get results back. โ€‹
  • madhumurundi
    madhumurundi
    Re: JAVA NETWORKING basics for Projects..contd...

    What Is a URL?
    Definition: URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the Internet.
    If you've been surfing the Web, you have undoubtedly heard the term URL and have used URLs to access HTML pages from the Web. It's often easiest, although not entirely accurate, to think of a URL as the name of a file on the World Wide Web because most URLs refer to a file on some machine on the network. However, remember that URLs also can point to other resources on the network, such as database queries and command output.



    The following is an example of a URL which addresses the Java Web site hosted by Sun Microsystems:
    [โ€‹IMG] As in the previous diagram, a URL has two main components:
    • Protocol identifier
    • Resource name
    Note that the protocol identifier and the resource name are separated by a colon and two forward slashes. The protocol identifier indicates the name of the protocol to be used to fetch the resource. The example uses the Hypertext Transfer Protocol (HTTP), which is typically used to serve up hypertext documents. HTTP is just one of many different protocols used to access different types of resources on the net. Other protocols include File Transfer Protocol (FTP), Gopher, File, and News. The resource name is the complete address to the resource. The format of the resource name depends entirely on the protocol used, but for many protocols, including HTTP, the resource name contains one or more of the components listed in the following table:
    Host Name The name of the machine on which the resource lives. Filename The pathname to the file on the machine. Port Number The port number to which to connect (typically optional). Reference A reference to a named anchor within a resource that usually identifies a specific location within a file (typically optional).
    For many protocols, the host name and the filename are required, while the port number and reference are optional. For example, the resource name for an HTTP URL must specify a server on the network (Host Name) and the path to the document on that machine (Filename); it also can specify a port number and a reference. In the URL for the Java Web site java.sun.com is the host name and an empty path or the trailing slash is shorthand for the file named /index.html.
    โ€‹
  • madhumurundi
    madhumurundi
    Re: JAVA NETWORKING basics for Projects..contd

    Creating a URL
    The easiest way to create a URL object is from a String that represents the human-readable form of the URL address. This is typically the form that another person will use for a URL. For example, the URL for the Gamelan site, which is a directory of Java resources, takes the following form:
    #-Link-Snipped-# โ€‹
    In your Java program, you can use a String containing this text to create a URL object:
    URL gamelan = new URL("https://www.gamelan.com/");
    โ€‹
    The URL object created above represents an absolute URL. An absolute URL contains all of the information necessary to reach the resource in question. You can also create URL objects from a relative URL address. โ€‹
    Creating a URL Relative to Another

    A relative URL contains only enough information to reach the resource relative to (or in the context of) another URL. Relative URL specifications are often used within HTML files. For example, suppose you write an HTML file called JoesHomePage.html. Within this page, are links to other pages, PicturesOfMe.html and MyKids.html, that are on the same machine and in the same directory as JoesHomePage.html. The links to PicturesOfMe.html and MyKids.html from JoesHomePage.html could be specified just as filenames, like this:
    #-Link-Snipped-#
    #-Link-Snipped-#
    โ€‹
    These URL addresses are relative URLs. That is, the URLs are specified relative to the file in which they are contained--JoesHomePage.html. In your Java programs, you can create a URL object from a relative URL specification. For example, suppose you know two URLs at the Gamelan site:
    #-Link-Snipped-#
    #-Link-Snipped-#
    โ€‹
    You can create URL objects for these pages relative to their common base URL: #-Link-Snipped-# like this:
    URL gamelan = new URL("https://www.gamelan.com/pages/");
    URL gamelanGames = new URL(gamelan, "Gamelan.game.html");
    URL gamelanNetwork = new URL(gamelan, "Gamelan.net.html");
    โ€‹
    This code snippet uses the URL constructor that lets you create a URL object from another URL object (the base) and a relative URL specification. The general form of this constructor is:
    URL(URL baseURL, String relativeURL)
    โ€‹
    The first argument is a URL object that specifies the base of the new URL. The second argument is a String that specifies the rest of the resource name relative to the base. If baseURL is null, then this constructor treats relativeURL like an absolute URL specification. Conversely, if relativeURL is an absolute URL specification, then the constructor ignores baseURL. This constructor is also useful for creating URL objects for named anchors (also called references) within a file. For example, suppose the Gamelan.network.html file has a named anchor called BOTTOM at the bottom of the file. You can use the relative URL constructor to create a URL object for it like this:
    URL gamelanNetworkBottom = new URL(gamelanNetwork, "#BOTTOM");
    โ€‹
    Other URL Constructors

    The URL class provides two additional constructors for creating a URL object. These constructors are useful when you are working with URLs, such as HTTP URLs, that have host name, filename, port number, and reference components in the resource name portion of the URL. These two constructors are useful when you do not have a String containing the complete URL specification, but you do know various components of the URL. For example, suppose you design a network browsing panel similar to a file browsing panel that allows users to choose the protocol, host name, port number, and filename. You can construct a URL from the panel's components. The first constructor creates a URL object from a protocol, host name, and filename. The following code snippet creates a URL to the Gamelan.net.html file at the Gamelan site:
    new URL("http", "www.gamelan.com", "/pages/Gamelan.net.html");
    โ€‹
    This is equivalent to
    new URL("https://www.gamelan.com/pages/Gamelan.net.html");
    โ€‹
    The first argument is the protocol, the second is the host name, and the last is the pathname of the file. Note that the filename contains a forward slash at the beginning. This indicates that the filename is specified from the root of the host. The final URL constructor adds the port number to the list of arguments used in the previous constructor:
    URL gamelan = new URL("http", "www.gamelan.com", 80,
    "pages/Gamelan.network.html");
    โ€‹
    This creates a URL object for the following URL:
    #-Link-Snipped-#
    โ€‹
    If you construct a URL object using one of these constructors, you can get a String containing the complete URL address by using the URL object's toString method or the equivalent toExternalForm method. โ€‹
    URL addresses with Special characters

    Some URL addresses contain special characters, for example the space character. Like this:
    #-Link-Snipped-# world/
    โ€‹
    To make theses characters legal they need to encoded before passing them to the URL constructor.
    URL url = new URL("https://foo.com/hello%20world");
    โ€‹
    Encoding the special character(s) in this example is easy as there is only one character that needs encoding, but for URL addresses that have several of these characters or if you are unsure when writing your code what URL addresses you will need to access, you can use the multi-argument constructors of the #-Link-Snipped-# class to automatically take care of the encoding for you.
    URI uri = new URI("http", "foo.com", "/hello world/", "");
    โ€‹
    And then convert the URI to a URL.
    URL url = uri.toURL();
    โ€‹
    MalformedURLException

    Each of the four URL constructors throws a MalformedURLException if the arguments to the constructor refer to a null or unknown protocol. Typically, you want to catch and handle this exception by embedding your URL constructor statements in a try/catch pair, like this:
    try {
    URL myURL = new URL(. . .)
    } catch (MalformedURLException e) {
    . . .
    // exception handler code here
    . . .
    }
    โ€‹
    See #-Link-Snipped-# for information about handling exceptions.
    Note: URLs are "write-once" objects. Once you've created a URL object, you cannot change any of its attributes (protocol, host name, filename, or port number).
  • madhumurundi
    madhumurundi
    Parsing a URL
    The URL class provides several methods that let you query URL objects. You can get the protocol, authority, host name, port number, path, query, filename, and reference from a URL using these accessor methods: getProtocol Returns the protocol identifier component of the URL. getAuthority Returns the authority component of the URL. getHost Returns the host name component of the URL. getPort Returns the port number component of the URL. The getPort method returns an integer that is the port number. If the port is not set, getPort returns -1. getPath Returns the path component of this URL. getQuery Returns the query component of this URL. getFile Returns the filename component of the URL. The getFile method returns the same as getPath, plus the concatenation of the value of getQuery, if any. getRef Returns the reference component of the URL.
    Note: Remember that not all URL addresses contain these components. The URL class provides these methods because HTTP URLs do contain these components and are perhaps the most commonly used URLs. The URL class is somewhat HTTP-centric. โ€‹
    You can use these getXXX methods to get information about the URL regardless of the constructor that you used to create the URL object.
    The URL class, along with these accessor methods, frees you from ever having to parse URLs again! Given any string specification of a URL, just create a new URL object and call any of the accessor methods for the information you need. This small example program creates a URL from a string specification and then uses the URL object's accessor methods to parse the URL:
    import java.net.*;
    import java.io.*;

    public class ParseURL {
    public static void main(String[] args) throws Exception {
    URL aURL = new URL("https://java.sun.com:80/docs/books/tutorial"
    + "/index.html?name=networking#DOWNLOADING");
    System.out.println("protocol = " + aURL.getProtocol());
    System.out.println("authority = " + aURL.getAuthority());
    System.out.println("host = " + aURL.getHost());
    System.out.println("port = " + aURL.getPort());
    System.out.println("path = " + aURL.getPath());
    System.out.println("query = " + aURL.getQuery());
    System.out.println("filename = " + aURL.getFile());
    System.out.println("ref = " + aURL.getRef());
    }
    }
    โ€‹
    Here's the output displayed by the program:
    protocol = http
    authority =
    host =
    port = 80
    path = /docs/books/tutorial/index.html
    query = name=networking
    filename = /docs/books/tutorial/index.html?name=networking
    ref = DOWNLOADING
    โ€‹
  • madhumurundi
    madhumurundi
    Re: JAVA NETWORKING basics for Projects..contd....

    Reading Directly from a URL
    After you've successfully created a URL, you can call the URL's openStream() method to get a stream from which you can read the contents of the URL. The openStream() method returns a #-Link-Snipped-# object, so reading from a URL is as easy as reading from an input stream. The following small Java program uses openStream() to get an input stream on the URL Yahoo Search - Web Search. It then opens a BufferedReader on the input stream and reads from the BufferedReader thereby reading from the URL. Everything read is copied to the standard output stream:
    import java.net.*;
    import java.io.*;

    public class URLReader {
    public static void main(String[] args) throws Exception {
    URL yahoo = new URL("https://www.yahoo.com/");
    BufferedReader in = new BufferedReader(
    new InputStreamReader(
    yahoo.openStream()));

    String inputLine;

    while ((inputLine = in.readLine()) != null)
    System.out.println(inputLine);

    in.close();
    }
    }
    โ€‹
    When you run the program, you should see, scrolling by in your command window, the HTML commands and textual content from the HTML file located at Yahoo Search - Web Search. Alternatively, the program might hang or you might see an exception stack trace. If either of the latter two events occurs, you may have to #-Link-Snipped-# so that the program can find the Yahoo server. โ€‹
  • madhumurundi
    madhumurundi
    Connecting to a URL
    After you've successfully created a URL object, you can call the URL object's openConnection method to get a URLConnection object, or one of its protocol specific subclasses, e.g. #-Link-Snipped-# You can use this URLConnection object to setup parameters and general request properties that you may need before connecting. Connection to the remote object represented by the URL is only initiated when the URLConnection.connect method is called. When you do this you are initializing a communication link between your Java program and the URL over the network. For example, you can open a connection to the Yahoo site with the following code:
    try {
    URL yahoo = new URL("https://www.yahoo.com/");
    URLConnection yahooConnection = yahoo.openConnection();
    yahooConnection.connect();

    } catch (MalformedURLException e) { // new URL() failed
    . . .
    } catch (IOException e) { // openConnection() failed
    . . .
    }
    โ€‹
    A new URLConnection object is created every time by calling the openConnection method of the protocol handler for this URL. You are not always required to explicitly call the connect method to initiate the connection. Operations that depend on being connected, like getInputStream, getOutputStream, etc, will implicitly perform the connection, if necessary.
    Now that you've successfully connected to your URL, you can use the URLConnection object to perform actions such as reading from or writing to the connection. The next section shows you how.
    โ€‹
  • madhumurundi
    madhumurundi
    Reading from and Writing to a URLConnection
    The URLConnection class contains many methods that let you communicate with the URL over the network. URLConnection is an HTTP-centric class; that is, many of its methods are useful only when you are working with HTTP URLs. However, most URL protocols allow you to read from and write to the connection. This section describes both functions. โ€‹
    Reading from a URLConnection

    The following program performs the same function as the URLReader program shown in #-Link-Snipped-#. However, rather than getting an input stream directly from the URL, this program explicitly retrieves a URLConnection object and gets an input stream from the connection. The connection is opened implicitly by calling getInputStream. Then, like URLReader, this program creates a BufferedReader on the input stream and reads from it. The bold statements highlight the differences between this example and the previous
    import java.net.*;
    import java.io.*;

    public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
    URL yahoo = new URL("https://www.yahoo.com/");
    URLConnection yc = yahoo.openConnection();
    BufferedReader in = new BufferedReader(
    new InputStreamReader(
    yc.getInputStream()));
    String inputLine;

    while ((inputLine = in.readLine()) != null)
    System.out.println(inputLine);
    in.close();
    }
    }
    โ€‹
    The output from this program is identical to the output from the program that opens a stream directly from the URL. You can use either way to read from a URL. However, reading from a URLConnection instead of reading directly from a URL might be more useful. This is because you can use the URLConnection object for other tasks (like writing to the URL) at the same time. Again, if the program hangs or you see an error message, you may have to set the proxy host so that the program can find the Yahoo server.
    โ€‹
    Writing to a URLConnection

    Many HTML pages contain forms-- text fields and other GUI objects that let you enter data to send to the server. After you type in the required information and initiate the query by clicking a button, your Web browser writes the data to the URL over the network. At the other end the server receives the data, processes it, and then sends you a response, usually in the form of a new HTML page. Many of these HTML forms use the HTTP POST METHOD to send data to the server. Thus writing to a URL is often called posting to a URL. The server recognizes the POST request and reads the data sent from the client.
    For a Java program to interact with a server-side process it simply must be able to write to a URL, thus providing data to the server. It can do this by following these steps:

    1. Create a URL.
    2. Retrieve the URLConnection object.
    3. Set output capability on the URLConnection.
    4. Open a connection to the resource.
    5. Get an output stream from the connection.
    6. Write to the output stream.
    7. Close the output stream.
    Here is a small servlet named #-Link-Snipped-# ( or if you prefer a #-Link-Snipped-# script ). You can use this servlet to test the following example program.
    The servlet running in a container reads from its InputStream, reverses the string, and writes it to its OutputStream. The servlet requires input of the form string=string_to_reverse, where string_to_reverse is the string whose characters you want displayed in reverse order.
    Here's an example program that runs the ReverseServlet over the network through a URLConnection:
    import java.io.*;
    import java.net.*;

    public class Reverse {
    public static void main(String[] args) throws Exception {

    if (args.length != 2) {
    System.err.println("Usage: java Reverse " +
    "https://" +
    " string_to_reverse");
    System.exit(1);
    }

    String stringToReverse = URLEncoder.encode(args[1], "UTF-8");

    URL url = new URL(args[0]);
    URLConnection connection = url.openConnection();
    connection.setDoOutput(true);

    OutputStreamWriter out = new OutputStreamWriter(
    connection.getOutputStream());
    out.write("string=" + stringToReverse);
    out.close();

    BufferedReader in = new BufferedReader(
    new InputStreamReader(
    connection.getInputStream()));

    String decodedString;

    while ((decodedString = in.readLine()) != null) {
    System.out.println(decodedString);
    }
    in.close();
    }
    }
    โ€‹
    Let's examine the program and see how it works. First, the program processes its command-line arguments:
    if (args.length != 2) {
    System.err.println("Usage: java Reverse " +
    "https://" +
    " string_to_reverse");
    System.exit(1);
    }

    String stringToReverse = URLEncoder.encode(args[1], "UTF-8");
    โ€‹
    These statements ensure that the user provides two and only two command-line arguments to the program. The command-line arguments are the location of the ReverseServlet and the string that will be reversed. It may contain spaces or other non-alphanumeric characters. These characters must be encoded because the string is processed on its way to the server. The URLEncoder class methods encode the characters. Next, the program creates the URL object, and sets the connection so that it can write to it:
    URL url = new URL(args[0]);
    URLConnection connection = url.openConnection();
    connection.setDoOutput(true);
    โ€‹
    The program then creates an output stream on the connection and opens an OutputStreamWriter on it:
    OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
    โ€‹
    If the URL does not support output, getOutputStream method throws an UnknownServiceException. If the URL does support output, then this method returns an output stream that is connected to the input stream of the URL on the server side--the client's output is the server's input. Next, the program writes the required information to the output stream and closes the stream:
    out.write("string=" + stringToReverse);
    out.close();
    โ€‹
    This code writes to the output stream using the write method. So you can see that writing data to a URL is as easy as writing data to a stream. The data written to the output stream on the client side is the input for the servlet on the server side. The Reverse program constructs the input in the form required by the script by prepending string= to the encoded string to be reversed. The serlvet reads the information you write, performs a reverse operation on the string value, and then sends this back to you. You now need to read the string the server has sent back. The Reverse program does it like this:
    BufferedReader in = new BufferedReader(
    new InputStreamReader(
    connection.getInputStream()));

    String decodedString;

    while ((decodedString = in.readLine()) != null) {
    System.out.println(decodedString);
    }
    in.close();
    โ€‹
    If your ReverseServlet is located at #-Link-Snipped-#, then when you run the Reverse program using
    #-Link-Snipped-# "Reverse Me"
    โ€‹
    as the argument (including the double quote marks), you should see this output:
    Reverse Me
    reversed is:
    eM esreveR
    โ€‹
  • madhumurundi
    madhumurundi
    Lesson: All About Sockets


    URLs and URLConnections provide a relatively high-level mechanism for accessing resources on the Internet. Sometimes your programs require lower-level network communication, for example, when you want to write a client-server application. In client-server applications, the server provides some service, such as processing database queries or sending out current stock prices. The client uses the service provided by the server, either displaying database query results to the user or making stock purchase recommendations to an investor. The communication that occurs between the client and the server must be reliable. That is, no data can be dropped and it must arrive on the client side in the same order in which the server sent it.
    TCP provides a reliable, point-to-point communication channel that client-server applications on the Internet use to communicate with each other. To communicate over TCP, a client program and a server program establish a connection to one another. Each program binds a socket to its end of the connection. To communicate, the client and the server each reads from and writes to the socket bound to the connection.
    #-Link-Snipped-#

    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. The java.net package provides two classes--Socket and ServerSocket--that implement the client side of the connection and the server side of the connection, respectively. โ€‹
    #-Link-Snipped-#

    This page contains a small example that illustrates how a client program can read from and write to a socket. โ€‹
    #-Link-Snipped-#

    The previous page showed an example of how to write a client program that interacts with an existing server via a Socket object. This page shows you how to write a program that implements the other side of the connection--a server program. โ€‹
  • manvikareddy
    manvikareddy
    Hello.......iam thinking to my MSC project on networking.....Can you please give me some ideas regarding the projects on networking....Thank you.... Waiting for your reply...I need your ideas as soon as possible....Thank you....

You are reading an archived discussion.

Related Posts

I am a Computer Science & Engineering student pursuing my B.Tech. from NIT Bhopal. I am presently in my 5th semester. I am planning to do my internship at the...
hi i need to control postion of a motor using digital pid actually i m doing a project on plate mounted inverted pendulum mean a pendulum would be attached to...
Hi buddies you can rip PC games with the help uhc software.. google it and then you install it.. juz specify the installed games for it and then compress it...
Although very (very) late, but Surat is all set to become the first city in India to use GPS. The GPS will be used to accurately collect and locate physical...
Wordpress 2.8.5 Hardnering release is now available for download from WordPress โ€บ Blog Tool and Publishing Platform Important features - A fix for the Trackback Denial-of-Service attack that is currently...