Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet

 
Bill fake
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you help me in making this into applet.
thanks in advance..
SERVER
*********
import java.net.*;
import java.io.*;
public class server extends Thread
{
ServerSocket sersoc;
Socket client;

public server()
{
try
{
sersoc=new ServerSocket(8080);
while(true)
{
try
{
client=sersoc.accept();
processclient pc=new processclient(client.getInputStream(),client.getOutputStream());
pc.start();
}
catch(Exception e)
{
System.out.println("Error: "+e.getMessage());
System.exit(0);
}
}
}
catch(Exception e)
{
System.out.println("error :"+e.getMessage());
System.exit(0);
}
}
public static void main(String args[])
{
server vserver=new server();
}
}
class processclient extends Thread
{
BufferedReader in;
PrintWriter out;
String msg;

public processclient(InputStream is,OutputStream os)
{
super();
in=new BufferedReader(new InputStreamReader(is));
out=new PrintWriter(os,true);
}
public void run()
{
while(true)
{
try
{
msg=in.readLine();
System.out.println(msg);
out.println(msg);
}
catch(Exception e)
{
System.out.println("error: "+e.getMessage());
System.exit(0);
}
}
}
}

CLIENT***
************
import java.net.*;
import java.io.*;
public class client
{
Socket client;

BufferedReader keyin;
BufferedReader in;
PrintWriter out;
String keyinput;
String msg;

public client()
{

try
{

client=new Socket("127.0.0.1",8080);
keyin=new BufferedReader(new InputStreamReader(System.in));

in=new BufferedReader(new InputStreamReader(client.getInputStream()));
out=new PrintWriter(client.getOutputStream(),true);

while(true)
{
try
{
keyinput=keyin.readLine();

out.println(keyinput);

msg=in.readLine();
System.out.println(msg);
}
catch(Exception e)
{
System.out.println("error: "+e.getMessage());
}
}
}
catch(Exception e)
{
System.out.println("error :"+e.getMessage());
}
}
public static void main(String args[])
{
client vclient=new client();
}
}
 
Peter Gragert
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See more or less the same question (nearby)
Your wish is not the normal way to use applets!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic