Results 1 to 2 of 2
Thread: concurrent access to a Socket()
- 10-19-2009, 04:21 PM #1
Member
- Join Date
- Sep 2009
- Location
- Gouda, the Netherlands
- Posts
- 24
- Rep Power
- 0
concurrent access to a Socket()
Hi,
Can one do a read on a socket while an other thread does a write in the same time on the same socket?
- 10-19-2009, 04:56 PM #2
Yes you can. Though i would be careful not to write with two threads at the same time if you message is split up into multiple parts. I put a lock on the write stream before i use it.
Java Code:synchronized(output) //lock the object { //write to the output stream }My Hobby Project: LegacyClone
Similar Threads
-
Concurrent trail example
By bert682 in forum Threads and SynchronizationReplies: 4Last Post: 10-11-2009, 04:47 PM -
RCU in Java? or some list/set/etc. which can handle concurrent access?
By flok in forum Threads and SynchronizationReplies: 1Last Post: 09-14-2009, 10:59 PM -
append response to the request from Socket and write to another socket
By vaibhav_singh_vs@yahoo.co in forum NetworkingReplies: 3Last Post: 04-17-2009, 07:02 PM -
FileLock and file access from concurrent threads..
By fxRichard in forum Advanced JavaReplies: 5Last Post: 01-02-2009, 08:08 PM -
Concurrent Applications
By m@tqi in forum Advanced JavaReplies: 1Last Post: 12-01-2007, 12:09 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks