Showing posts with label Mini-Project. Show all posts
Showing posts with label Mini-Project. Show all posts

Friday, September 5, 2008 | | 0 comments

Simplest network Program in Java

Before going to a GUI network program, I decided to write a simple network program in Java. Wrote it and code is given below. A network program in Java can not be simpler than this. basically this program has two files.
  • s.java
  • c.java
s and c stands for server and client respectively. client sends a piece of text "This is the simplest text" to server. Server displays it. Thats all. Simple Huh!

s.java:


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

class s
{
ServerSocket servSoc=null;
DataInputStream din = null;
String s;
Socket soc;

s()
{
try{
servSoc=new ServerSocket(2008);
soc=servSoc.accept();
din=new DataInputStream(soc.getInputStream());

while(true)
{
s=din.readLine();
System.out.println(s);

}
}
catch(Exception e){}
}
public static void main(String ars[])
{
s s1=new s();

}
}



c.java:


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

class c
{
Socket soc = null;
PrintWriter pr=null;

c()
{
try{
soc=new Socket("localhost",2008);
pr=new PrintWriter(soc.getOutputStream(),true);
pr.println("This is the simplest text");
}
catch(Exception e)
{}

}
public static void main(String args[])
{
c c1=new c();
}
}


Sunday, August 31, 2008 | | 0 comments

A CLI Java Network Application

Finally, I did make a simple Command Line Java network application to work. In fact, I just copied it from this "Creating simple Chat client" available at Internet. But I learned each and every line of code in it, the only thing I wanted.

Now I'm going to make it work in a GUI. As per now, I have succeeded partially. On way I learned theory of Sockets classes in Java which implements(not in the Java sense) it.

I will post my updates after completing it. Oh, almost forgot....I will be doing this project as a network application.

Saturday, August 30, 2008 | | 0 comments

Mini project in Java

Hi, I'm Vishnu Prathish from College of Engineering Trivandrum. We have to submit a mini project for our 5th semester for evaluation. We mean to do it in Java though I'm not well versed with it. So I started this blog to keep track the course in which I'm learning Java and eventually we develop our project.

I begin here....