This blog aims at helping you learn C, Java and TASM programming languages and thus enabling you to use its immense possibilities in the computing world.It features Step by step instructions on doing a C program ,Complete Source Codes of C, Java and TASM Programs ,sample program downloads,programming tutorials and general tips for programmers.

TCP/IP(Transmission Control Protocol/Internet Protocol) :Is connection based protocol that is widely used over the internet.It is commonly referred to as IP.The following program uses TCP/IP to communicate.

After reading the above article,see the code below.You can see how socket and server sockets are used to create a one way client server program.Here a client can communicate with the server only.Both are DOS/Terminal Java Programs.

Fist you start the server program followed by client program in two separate terminals.In the client terminal type anything,you can see that appearing in the server terminal window.

The complete Java Program source code to implement 1 way client and server model is provided below as two separate programs Client.java and Server.Java

Friday, March 9, 2012

Socket: A socket is one end-point of a two-way communication link between two programs running on the network.java.net Package provides support for sockets.
Socket classes can be used to implement the connection between a client program and a server program.

ServerSocket:ServerSocket class is exclusive for the Server side implementation of the client-server model.

Java programming with Socket class allows easy implementation of a client-server model for one way or two way communication.
We can easily implement a simple one way client server model,2 way client server model,a broad cast server,a multicast server using Sockets and Server Sockets in Java.

courtesy:oracle

Client Side Basically a socket can used in a client to send message it involves creation of socket by using the code

Socket mysocket=new Socket(localhost,2000)

Here a socket is created in the local machine itself you can specify theip address of the server machine instead of localhost.

Server Side

In the Sever Side a ServerSocket is created.ServerSocket is a differentclass rather than socket.It is meant for the server side only.In the server side the following code is usually used

ServerSocket ssock=new ServerSocket(2000)

As you can see the same port number should be used in the client and server side.

Classes like PrintStream is used to send message from the client to the server.It is established easily like this

PrintStream ps=new PrintStream(mysocket.getOutputStream)

ps.println("my message");

This code in the client side sends message to the server.In the server side this message can be easily accepted and displayed using the following code

ServerSocket ssock=new ServerSocket(2000)

Socket mysocket=ssock.accept()

DataInputStream d=new DataInputStream(mysocket.getInputStream)

String msgfromserver=d.readLine()

System.out.println(msgfromserver)

The method accept() is used to accept a connection from the client.Note that you need to surround the statements with a try-catch block to handle all the exceptions.In this way you can send a message from the client to server.

Thursday, March 8, 2012

Hybrid Inheritance is the combination of two or more inheritances : single, multiple,multilevel or hierarchical Inheritances.
The following is a C++ Program to for Calculating the marks secured by a student.A Parent class with student identification is created
and another class called marks is inherited from the main class.This class marks is further inherited by another class called sports and finally the sports class is inherited by the percentage class to calculated the percentage of marks.This is the best example for Hybrid Inheritance in c++The complete source code is provided Below