Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can somone tell me why My network isnt working

Status
Not open for further replies.

KohlerChris

Programmer
Jul 8, 2001
5
AU
WEll u see i can connect alright i know that they connect, but when i goto my method in setting up my input and oput streams as below i dont work
try{
so = new ObjectInputStream(MWSocket.getInputStream());
sp = new ObjectOutputStream(MWSocket.getOutputStream());
}catch(Exception e){}
can somone possibly gove me some suggestions of how to set up these or send ,me some code that you have dont on networking before?
 
Hi KohlerChris,

The problem is that InputStream is blocking. So I think that you have a situation where both client and server first creates InputStream -> that leads to the situation that both sides are blocking and OutputStreams are never created.
So the sollution is: Create OutputStreams first;

sp = new ObjectOutputStream(MWSocket.getOutputStream());
so = new ObjectInputStream(MWSocket.getInputStream());

(Its good idea to do the same thing at client side too...)

...that InputStream blocking in worth of remembering

I hope that helped you!
 
I would recommend 2 threads 1 for reading input and the other for normal processing(including output). This way, it would be easier to edit your program in time to come; You don't always have to make sure that the server is sending and the client is reading or the other way round since there an inputstream is always opened.

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top