Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Server receives  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm a junior java developer who has primarily worked with servlets and some GUI stuff; but I now am stuck on RMI!! I am writing the Server portion whose job is to give permission to the
Client to send(no problem here), but also to handle receiving Objects sent by the Client(This is the problem).
How do I implement this? What would I need to add into the server program so that the server receives each object and then sends it to another program for storage or writing purpose.
I would appreciate any help whatsoever!
 
tony simon
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well if the client is writing as an object ,in the server side U can read as below:
(Hope this is what U meant
============================================
String idtoget=""; //The type of object he is sending
String texttoget="";//The type of object he is sending

ss=new ServerSocket(7000);
while(true)
{
try
{
s=ss.accept();//Accepts A connection
System.out.println(s.getInetAddress());
is=s.getInputStream();
objis=new ObjectInputStream(is);
}catch(IOException e) {System.out.println "The error inside SS :"+e);}

try
{
idtoget=(String)objis.readObject();
texttoget=(String)objis.readObject();
System.out.println(idtoget);
System.out.println(texttoget);
} catch(IOException e1){System.out.println("The error inside while reading :"+e1);}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!