Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
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. 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.

 

                         

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 
Latest Searches:
chartinservlet
sequence number genara
what is interface in j
count column tabl
convertstringtostingof
Tutorial:FlashBasicPas
field validators
cd change directory in
textboxinjspusingajax
PhotoshopBasicsStained
round of number
jsp bean get property
in photoshop how to ma
how to call pl/sql fro
clear the screen in ja
open file with optionp
java4features
columnwidthPOI
java charts
JText Area
read integers from fil
how%20to%20send%20emai
modify
netbeans jsp
login jsp
hibernatefind(object)
stringbuffertoxmlobjec
PHP Email Systems Send
read space character f
openGL
substring(int,int)
jQuery To Hide the Div
class file stored
architecture of a serv
jsf tree node set hr
request.getParameterVa
swing
documentwrite
sending SMS in JAVA
grantchart
Reading File into Byte
click on radio button
jar file
exportdatabasedatainto
Photoshop Wave effect
highlighting and dehig
MurachÐ?????Ð????Ð???Ð
linking codes in java
jsf chat tomcat eclips
Photoshop Effects Hole
shellscriptsusingunixc
passing values from js
Quick Sort
userdefinedexceptionsa
JFileChoosershowOpenDi
network
programinjavatodrawrec
struts pdf file free d
j2me stringItem
Flash Dynamic Content
Combattons
input in java
Agents() in Ms-excel
java bean insert conne
logic iterate
populate drop down fro
Array in Java
InvalidCancelException
int to string
applet viewer browse t
Program to gather Cust
Photoshop Digital Art
strutshibernateexample
upload file using jsp
deploy a JSP and servl
json lib/components/co
json lib/components/co
selectingmultiplefileu
display image
log4j:WARN No appender
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

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 | 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.