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 4 2736
Hi Macca,
don't have a direct answer, but I always liked the Indy Sockets library
for Delphi to simplify building network client/servers: http://www.indyproject.org/Sockets/index.en.iwp
There's a .NET version now, but have never used it yet.
Regards,
Wiebe Tijsma
Macca wrote: 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
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" <Ma***@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
|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
Hi William,
Thanks for the advice. I've been told to use asynchronous sockets as the
code already exists. I would appreciate it if you can tell me how other
threads in the app could communicate with asynchronous sockets?
Thanks
Macca
"William Stacey [MVP]" wrote: 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" <Ma***@discussions.microsoft.com> wrote in message news:3E**********************************@microsof t.com... |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
Not sure I know what you mean. async server logic can get very complicated
and can not give you a one size fits all answer. It all depends on your
code and what your doing. How many clients will be connected at one time?
You may want to using a work crew sync server instead as it is much easier
to code correctly.
--
William Stacey [MVP]
"Macca" <Ma***@discussions.microsoft.com> wrote in message
news:B8**********************************@microsof t.com...
| Hi William,
|
| Thanks for the advice. I've been told to use asynchronous sockets as the
| code already exists. I would appreciate it if you can tell me how other
| threads in the app could communicate with asynchronous sockets?
|
| Thanks
| Macca
|
| "William Stacey [MVP]" wrote:
|
| > 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" <Ma***@discussions.microsoft.com> wrote in message
| > news:3E**********************************@microsof t.com...
| > |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
| >
| >
| > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Corne Oosthuizen |
last post by:
I'm writing a Telnet Server application using
Asynchronous sockets.
I spawn a listener thread to handel incomming connections
and create a separate client socket for each new
connection.
I...
|
by: Droopy Toon |
last post by:
Hi,
I am using asynchronous socket (BeginAccept for example).
I tried to name each thread I am using but threads created by
asynchronous Socket functions (like BeginAccept) creates "anonymous"...
|
by: Colin |
last post by:
I'm writing a little console socket server but I'm having some
difficulty. Can I ask your advice - where is the best place to get
some help on that topic? It would be nice if some people who knew...
|
by: Macca |
last post by:
My app has an asynchronous socket server. It will have 20 clients connected
to the server. Each client sends data every 500 millisecondsThe Connections
once established will not be closed unless...
|
by: Macca |
last post by:
Hi,
I am writing an asychronous socket server to handle 20+ simulataneous
connections.
I have used the example in MSDN as a base. The code is shown at end of
question.
Each connection has a...
|
by: Engineerik |
last post by:
I am trying to create a socket server which will listen for connections from
multiple clients and call subroutines in a Fortran DLL and pass the results
back to the client. The asynchronous socket...
|
by: Pat B |
last post by:
Hi, I'm writing my own implementation of the Gnutella P2P protocol
using C#. I have implemented it using BeginReceive and EndReceive
calls so as not to block when waiting for data from the...
|
by: Nicolas Le Gland |
last post by:
Hello everyone here.
This is my first post in this newsgroup, I hope I won't be to much
off-topic. Feel free to redirect me to any better group.
I am getting strange timing issues when...
|
by: keksy |
last post by:
Hi every1,
I am writing a small client/server application and in it I want to
send an image asynchronous from the client to the server through a TCP
socket. I found an example code on the MSDN...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |