11-10-2010 04:28 PM
I want to build a mechanism that opens a socket connection to a server and then independently send and receive messages to and from server on this connection. My approach is like this: from main thread I launch a thread (ignition thread) that opens a StreamConnection (socket://iport;deviceside=true) and get DataInputStream and DataOutputStream objects out of it. Using DataInputStream I create another thread (since reading and writting will be independent - wondering still if it is possible) only for input data. I will then use a notification mechanism to use received data.
DataOutputStream is then used for writting operations ...
Problem I have:
Writting seems to be fine as I can see logs just before and after DataOutputStream writeUTF and flush methods, but the reading fails with a "General " IOException. Now, I assumed this StreamConnection can handle independent input / output operations ... If not, is there a way of doing it?
Has anyone done this independent in and out operations?
Solved! Go to Solution.
11-13-2010 07:49 AM
From memory, other people have reported issues with attempting to process the same socket connection connection in different directions using different Threads. I would not do this. If you need full duplex, then start a second socket.
11-13-2010 10:24 AM
Thank you for your response! ... I haven't found anything related to my problem and I didn't find anyone having the same issue. Do you remember where have you seen posts with sharing the same socket connection in 2 threads?