Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Internet Socket Q

  Asked By: Reginheraht    Date: Jun 22    Category: Java    Views: 936
  

Actually I'm not good in Java. But I should do this part, and I really confused how to write the code. Could someone help me to do this part?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Whitney Cruz     Answered 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.

 
Answer #2    Answered By: Asir Hashmi     Answered On: Jun 22

I think you have passed your exam; if so, why are you looking for the solution?

 
Didn't find what you were looking for? Find more on Internet Socket Q Or get search suggestion and latest updates.




Tagged: