Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
GetKeepAlive 
 

In this section, you will show the used of several method for different output massage. Here, we provide a complete example based on the method for creating the Socket() method. Firstly create a class named of "getKeepAlive" and initialize a class Socket

 

GetKeepAlive

                         

In this section, you will show the used of several method for different output massage. Here, we provide a complete example based on the method for creating the Socket() method. Firstly create a class named of  "getKeepAlive" and initialize a class Socket. The main purpose of the server socket is to listen an incoming connection request and ordinary socket is used to ask to server for the connection. Here, we are going to explain the method to find out the local address of local system. This is the program also represent the several information about the server socket. 

Code Description:

getKeepAlive():
This is the method returns a boolean indicating whether or not SO_KEEPALIVE is enabled.

getSendBufferSize():
This method gets the value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.

isOutputShutdown():
This method returns whether the write-half of the socket connection is closed. This method returns true if the output of the socket has been shutdown.

getPort(): This method returns the port number of local  machine.

getLocalSocketAddress(): This is the method returns the address of the endpoint this socket.

Here is the code of  this program:

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

public class 
getKeepAlive{
  public static final short TIME_PORT = 135;
  public static void main(String[] argsthrows IOException{
    String hostName = null;
    System.out.println();
    try{
      Socket socket= new Socket(hostName,TIME_PORT);
      System.out.println("socket =" + socket);
      System.out.println("Keep Alive="+ socket.getKeepAlive());
      System.out.println("Send Buffer size ="+ socket.getSendBufferSize());
      System.out.println("output ="+socket.isOutputShutdown());
      System.out.println("port is =" + socket.getPort());
      System.out.println("socket address ="+socket.getLocalSocketAddress());
      InetAddress in= socket.getInetAddress();
      System.out.println(in);
      System.out.println("\n");
      System.out.print("RAW IP Address - (byte[]) : ");
      byte[] b1 = in.getAddress();
      for (int i=0; i< b1.length; i++) {
        if (i > 0) {
          System.out.print(".");}
          System.out.print(b1[i]);
      }

    }
    catch (UnknownHostException  e)  {
      e.printStackTrace();
    }
    catch (IOException e) {
      e.printStackTrace();
    }
  }
}



Output of  this program:

 C:\rose>java getKeepAlive

socket =Socket[addr=localhost/127.0.0.1,port=135,localport=1302]
Keep Alive=false
Send Buffer size =8192
output =false
port is =135
socket address =/127.0.0.1:1302
localhost/127.0.0.1

RAW IP Address - (byte[]) : 127.0.0.1
C:\rose>

 

Download of this program.

 

                         

» View all related tutorials
Related Tags: c com forms server orm form network socket io sed request return opera ai for work wait to base pos

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.