> I've looked at the Class you mentioned - it's not possible with a few lines
> of code, to make this work in a multithreaded AX-Exe-Environment.
[quoted text clipped - 7 lines]
>
> Olaf
Thanks again for your reply.
Well, actually the app that I am doing is kind of message distributor,
with a server listening for connection (could be 10, 20, or even
more). Whenever there is a message received from one of the client
app, this server app is then resposible to distribute the message to
the respective recepient modules (could be 1, 2 or more).
My current design is to have a buffer storing incoming message, and a
timer where the distributing of the message take place. In the timer
event, the server would then get the message out from the buffer and
send it to respective client modules, without any heavy processing on
the message. In this case the sending of message to the recepient
module is in sequence, making it possibly delay if there is many
receipient modules for the particular message. The problem would
become more obvious if I were to put in the message acknowledgement,
timeout and resend (this is needed to solve the incapability of the
server app to detect the network problem at client).
So what I can think of to oversome this possible problem is to create
a worker thread which the server can just simply pass the message to
it without worrying about the message acknowledgement etc. So each
worker thread should then have their own buffer to store the incoming
message, and send it out one by one.
By this, I think the idea that you have suggested would not applicable
here. Any advice?
J.
Schmidt - 28 Apr 2005 09:27 GMT
> By this, I think the idea that you have suggested would not
> applicable here. Any advice?
Workers in a multithreaded environment are needed, to handle blocking,
timeconsuming jobs. Since your reasons for blocking are
socket-send-problems, it's not the worst idea, to put them into threads.
You wouldn't have a problem with that (App could stay singlethreaded), if
your socket-class would be capable, to send Buffers out async and detect
receive-problems at the client instantly. There are socket implementations,
wich are capable of those things. Your's is not.
So you can either stay singlethreaded and enhance to async socket-send
capabilities (implement it yourself per WriteFile or WsaSend-APIs or use
another socket-implementation wich is capale of that) - or work with threads
(pass the content and the sockethandle of an accepted socket and use the
modified SendBufferedDataTCP-function of your socket-class inside the
worker).
Olaf