Hi Thomas,
"Thomas Pornin" <> wrote in message
news:4b9f9a05$0$22008$...
> According to Richard Maher <>:
> > Can someone please confirm that for a given Socket with a
> > BufferedInputStream "in" and a BufferedOutputStream "out", I can have
> > one thread T1 executing a series of out.write()s followed by an
> > out.flush() without explicit locking or synchronizing that will in
> > noway interfere with another Thread T2 that is happily performing one
> > (or more until we get "n" bytes) in.reads?
>
> I can confirm. It is true without the buffered streams as well. The two
> streams associated with a socket are independent from each other, save
> for what happens upon closing either (or the socket itself). But
> explicit synchronization is not needed either for that anyway.
>
>
> > IOW, one T1 is sending messages as it likes to a remote server and T2
> > is processing the response messages. I want this all to happen in
> > parallel and without explicit thread-synching or lock/mutexing. Is
> > that architecturally sound given the classes that I am using?
>
> It is actually sounder than many other architectures, if data may
> be transmitted in both directions simultaneously.
>
>
> > PS. For the sake of argument please assume that T1 is sending random
> > numbers and T2 is just doing System.out.println() i.e pretend the
> > reader and writer are completely independent.
>
> If reader and writer are _not_ completely independent, then the problem
> becomes more complex. Depending on how they interact. One possible
> interaction being on the remote side of the socket, of course. An
> example is that of a HTTP client. Theoretically, the HTTP client may
> send several requests in a row, asynchronously reading the responses,
> but each response corresponds to one request, in due order. The client
> must match requests and responses and there lies potential trouble.
> Fortunately, the JVM comes with a HTTP client which already does all
> that hard work.
Thanks for confirming that for me.
>
> There is a subliminal message here: maybe you should try to use HTTP
> as a transport mechanism ? Sun's JVM already comes with an HTTP client
> _and_ an HTTP server. The HTTP client uses java.net.URL. For the HTTP
> server, see:
>
http://java.sun.com/javase/6/docs/jr...e-summary.html
>
>
No a *signle*, secure, authenticated, connection-oriented, context-rich
protocol will be just fine thanks.
> --Thomas Pornin
Cheers Richard Maher
PS. For those with a love-affair for HTTP and the school of thought that
says "Hey, I reakon BSD(ish) TCP/IP Sockets would be much better implemented
over HTTP" then you'll probably love the *******s the HTML5 people have come
up with
See
http://cometdaily.com/2010/03/02/is-...t-chat-simple/ for just some
issues.
You just can't make a silk middleware-backbone out of a pig's http!