Socket Server - Two Problems

The first problem is I can't get the OutputStream.println function to work. The socket connection is fine and working because I can receive data from a connected client.

PrintStream out =new PrintStream(new BufferedOutputStream(server.getOutputStream()));

out.println("example_string");

out.flush();

If anything else needed or should that work fine?

The second problem is accessing threads so that the OutputStream can be used and data is only sent to certain socket connections. I'm not sure if you can access the variables and functions inside a thread but if you can't then is there some kind of alternative?

[743 byte] By [EGONicka] at [2007-11-27 1:03:35]
# 1
Try with PrintWriter... I usually do it that way, and it always works fine.And yes, you can access only the thread you need.
jadespirita at 2007-7-11 23:38:40 > top of Java-index,Core,Core APIs...
# 2

I would avoid both PrintWriter and PrintStream over the network, as they swallow exceptions. Having said that, the code you've shown is all you need as long as no exception is being thrown - check that - and the problem may be at the other end: are you using a readLine() method? or something else?

ejpa at 2007-7-11 23:38:40 > top of Java-index,Core,Core APIs...