473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Asynchronous socket server

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
Feb 11 '06 #1
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

Feb 11 '06 #2
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
Feb 13 '06 #3
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

Feb 17 '06 #4
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
| >
| >
| >
Feb 18 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
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...
5
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"...
7
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...
2
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...
0
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...
4
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...
6
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...
2
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.