Re: Asynchronous socket server

Tech-Archive recommends: Speed Up your PC by fixing your registry



For 30 devices you don't really need the added complication of async
processing.
1) Create a listener thread the accepts connection.
2) Create a new thread (i.e. WorkerObject) for each connection and pass it
the TcpClient.
3) The thread will handle reads and write syncronously and quit.

In this way, you don't even need the queue or locking on it. If you like
the queue, a neat way to do this would be a UserThreadPool with some max 30
workers. Then just queue the TcpClients to the thread pool and each TP
thread will handle the end-to-end conversation with the client and quit -
ready to handle the next item in the queue.

--
William Stacey [MVP]

"Macca" <Macca@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3E1405EB-31C3-4F77-9180-36B1D9BD25A0@xxxxxxxxxxxxxxxx
|I am writing an application that uses asynchronous sockets to get data over
| ethernet from embedded devices, up to 30 concurrent devices.(These devices
| are written in C).
|
| My application implements an asychronous socket server while the embedded
| devices are the clients
|
| When the data comes in over the socket it is eventually passed into a
| message queue.
|
| A separate thread in the app is responsible for taking the data off of the
| queue and then processing it.
|
| This thread and/or others will need to be able to send data back to the
| distributed embedded devices.
|
| The problem i am having is how to achieve this. I'm not sure how these
| threads can pass data to or communicate with the asynchonous socket server
to
| send data back to the clients.
|
| The MSDN example has the socket server immediately sending data back to
all
| clients connected to it. (App is a chat spplication)
|
| This is not what i want to do though as I have explained above.
|
| I know there socket server has an asychronous send method. Do i use this
| some way? If so how do I use it with the other threads in my app?
|
| I'd appreciate any advice that anyone could give me.
|
|
| Thanks In Advance
| Macca


.



Relevant Pages

  • Re: Problem with socket programming
    ... if there are 10 clients in the socket server pending ... That is why I want to get the socket server pending queue number. ...
    (comp.os.linux.development.apps)
  • Connections must be forced
    ... Messages hang in the Queue ... until the connection is forced. ... clients. ... Bill ...
    (microsoft.public.exchange2000.general)
  • Re: The "Reconnect" Problem
    ... requests over the same connection. ... processes a queue of pending requests to be sent. ... Clients that want to send messages put them into a queue. ...
    (comp.programming.threads)
  • Re: Thread pool; trouble dividing tasks into work items.
    ... Register your timer and socket with the network monitoring thread. ... the connection is typically going to be busy: ... timer queue, and using that to expire tasks. ... Create a work item to send data over network, add to thread pool. ...
    (comp.programming.threads)
  • Re: start a multi-sockets server (a socket/per thread) with different ports but same host
    ... def newthread: ... I am doing a small project using socket server and thread in python. ... different port. ... I want all socket servers start up and wait for client connection. ...
    (comp.lang.python)