Search This Blog

Loading...
If you like any posts in this blog then click this icon which is present under the post

Monday, 24 October 2011

CRC Using TCP

client
import java.io.*;
import java.net.*;
import java.util.*;
class crccli
{
    public static void main(String args[])
    {
    try
    {  
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        Socket clsct=new Socket("127.0.0.1",139);
   

Wednesday, 12 October 2011

Creating Objects


                 Creating objects means to allocate memory space for all the instance variables of the objects. Step to create an object are,

1. Declare an object.
2. Define the object using new operator. The new operator dynamically allocates memory for an object and returns a reference to it.
The general form is
1. Declare an object.
2. Define the object using new operator. The new operator dynamically allocates memory for an object and returns a reference to it.

Adding Variables and Methods


Adding variables
                 To a variable in a class it must be defined inside the class. At once a variable is added to a class it becomes instance variable.
Example
                class Student
                {
                                int reg_no;
                                 int mark_1;
                                int mark_2;

Defining a Class


                A class is a user defined data type. It contains data and its related methods. The general form is

class classname
{
     Datatype field-1;
      ……………………….
     Datatype field-n;
     Datatype methodname-1(parameter list)
     {
           Body of the method
      }
     ………………………..
     Datatype methodname-n(parameter list)
     {
          Body of the method
     }
}

Classes and Objects


  1.          Java is a pure object oriented language. 
  2.          So java program contains only classes. 
  3.          Each class has its own data items and functions. 
  4.          The data items are called fields and the functions are called methods.
  5.          A class is a user defined data type and it represents the template of the fields and its related methods. 
  6.          Object is a variable of type class and is used to access the class.

Monday, 10 October 2011

Program for Hormonic series

Program
import java.io.*;
class HormonicSeries
{
    public static void main(String args[])
    {
        float s=0f;int n=0;
        try
        {

Wednesday, 28 September 2011

Finding class of the IP address


Client:
import java.io.*;
import java.net.*;
import java.util.*;
class Clientip
{
            public static void main(String args[])
            {
            try
            {
                        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
                        Socket clsct=new Socket("127.0.0.1",139);
                        DataInputStream din=new DataInputStream(clsct.getInputStream());
                        DataOutputStream dout=new DataOutputStream(clsct.getOutputStream());

Tuesday, 27 September 2011

RPC and RMI operation in java


Client
import java.io.*;
import java.net.*;
import java.util.*;
class Clientrpc
{
            public static void main(String args[])
            {
            try
            {
                        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
                        Socket clsct=new Socket("127.0.0.1",139);
                        DataInputStream din=new DataInputStream(clsct.getInputStream());
                        DataOutputStream dout=new DataOutputStream(clsct.getOutputStream());

Stop and Wait in Java


Client
import java.io.*;
import java.net.*;
import java.util.*;
class Clientstop
{              public static void main(String args[])
                {try{while(true)
                                {String str1=null;
                                BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
                                Socket clsct=new Socket("127.0.0.1",139);
                                DataInputStream din=new DataInputStream(clsct.getInputStream());
                                DataOutputStream dout=new DataOutputStream(clsct.getOutputStream());

Bitstuffing in java


Client
import java.io.*;
import java.net.*;
import java.util.*;
class Clientbs
{              public static void main(String args[])
                {try{       BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
                                Socket clsct=new Socket("127.0.0.1",139);
                                DataInputStream din=new DataInputStream(clsct.getInputStream());
                                DataOutputStream dout=new DataOutputStream(clsct.getOutputStream());

Followers