NetTalk Central

Author Topic: Netsimple Server : Multi threading?  (Read 7761 times)

HalfBubble

  • Newbie
  • *
  • Posts: 13
    • Yahoo Instant Messenger - torby77
    • View Profile
    • Email
Netsimple Server : Multi threading?
« on: November 01, 2010, 12:53:26 PM »
When a packet comes in, I get the request data:

self.WholePacketQueue.WholeBinData

and the reply IP:

self.packet.FromIP

Would it be reasonable to start a thread, put the answer to the request in some queue, and use the send method to send the response back while watching for other requests? (The boss is asking, "Can it be multi-threaded?"

Oh yes, Clarion 6.3 something. Nettalk version 4.53
Tom Ruby
Clarion since Clarion for Windows 1.0
Available for short or long projects

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11181
    • View Profile
Re: Netsimple Server : Multi threading?
« Reply #1 on: November 03, 2010, 06:52:36 AM »
Hi Half (or should that be Bubble?)

The short answer is yes.
The server should store the incoming details (specifically the packet.sockid, packet.fromip etc), place the packet in say a queue. Then other threads could update the queue (*). And the parent thread could send the reply as required.

(*) - note that Queues are NOT thread-safe. So unless you _really_ know what you are doing, you should use a MEMORY driver FILE here, not a Queue.

Cheers
Bruce