it seems that I need a rewrite of this part of my
project from start on.

The idea is to have one dll for encapsulating all
communication stuff and another sitting on top of it
for handling of my special protocolls. because I have
more than one I can exchange these dlls sitting in top
as needed.

The application's use of sockets is fairly static: at start the needed
number of sockets will be created, they will be used and at exit of the
programm they will be closed. Normally no opening and closing in between
is required.

My new idea for the communication dll is as follows:
(this will only be the sending side so far, if that works I will build
the receiving one - these sockets can't be used for receiving just now
because the other hardware is "hardwired" to some adress which is one
central receiving adress for all connections altogether)

- it gets a dedicated thread which only sits in its
  execute method doing the following things:
  - wait for requests from outside to create a new socket
    (it will be created and added to the dll internal
     connection list, the outside will get a numeric handle,
     with that the outside can send data)
  - wait for requests to close a given socket
    (named through the numeric handle)
  - polling windows messages for ICS
  - when the thread gets the signal to finish itsself,
    it can look up in the connection list if there are
    any open sockets left which will get closed one after
    another then
  - if no sockets exist, it is idle and should sleep as much
    as possible

The questions are:
- is this concept okay? (won't crash or hang if
  implemented correctly)
- how to make the message pump in the thread?
  I can't simply call socket.processmessages, because I would
  have to look up a socket every time in the list
- can the message pump be constructed without the help of
  like this:

  while not terminated do
    // check for sockets to create
    // check for sockets to close

    // message pump like this
    while messages exist and not timeout do
      fetch next message
      process it
- if not, would it be sufficient to call processmessages
  only for one of these sockets?


To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to