Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / Java / JSP - Need help with server and client program

Author
Message
Mr Z
18
Years of Service
User Offline
Joined: 27th Oct 2007
Location:
Posted: 3rd Sep 2009 11:35 Edited at: 3rd Sep 2009 14:44
Hi all.

I am having problems with a school work. Basically I am making a network program as a school project, but I have trouble getting the network part to work. The issue comes when I try to send a byte array to the client (the program will work by exchanging byte arrays). The server accepts the connection from the client, sends the response, then closes the stream and dispose of the client handler. The client connects to the server, and is then supposed to read the data the server sends before it shuts down. However, no data is read. There is no exception, no hint on what it is wrong, it is like it just decides to ignore the data and pretend like there is no issue. I can make it work, if I send a int instead of a byte array, but I need to send a byte array.

This is my client code:


And this is the important server code (it has grown, so I cannot post all the code):

(There are no exceptions thrown in the code above, it just seems to work well.)

Anyone has a clue of what is wrong?

Take care,
Mr Z

EDIT:

Managed to solve it by using ObjectOutputStream instead. But I am still confused why it did not work to begin with .

"Operator! Give me the number for 911!"
- Homer J. Simpson
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Sep 2009 18:57
After you write your data to the stream you have to call flush() if you wish to actually send the data.

[url="http://www.nocleanfeed.com"][/url]

Login to post a reply

Server time is: 2026-06-10 05:53:49
Your offset time is: 2026-06-10 05:53:49