Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Reginheraht Fischer   on Jun 22 In Java Category.

  
Question Answered By: Whitney Cruz   on Jun 22

I dont think anyone would appreciate to solve your exam questions in this forum,
But since you are the NAKED TRUTH(isnt my fault, its her email address) and i kinda like that
I will give you some hints :

Client class has to implement something like:
// IP and PORT goes here
 socket  sock = new Socket("localhost", 9999);
// Data goes here
sock.getOutputStream().write("WHAT EVER YOU WANT");

Server class has to implement something like:

ServerSocket server = new ServerSocket(9999);
log.info("Waiting for connections...");
while (true) {
Socket sock = server.accept();
log.info(String.format("New connection from %s:%d", sock.getInetAddress(), sock.getPort()));
if (socket.getInputStream().read(lenbuf) == lenbufsize) {
socket.getInputStream().read(buf);
}
}

These are only hints and you have to read these topics in order to complete your application.

Share: