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"
threads.
I named the thread (see sample code below) in Accept callback started by
BeginAccept but all connections accepted run in a thread that has the
same name !
So, even a new thread is not started by BeginAccept, even my naming is
wrong.
Thanks in advance for your help.
code:
...
Socket server = new Socket (AddressFamily. InterNetwork,
SocketType.Stre am, Protocol.Tcp);
...
server.BeginAcc ept (new AsyncCallback (AcceptConnecti on), server);
...
void AcceptConnectio n (IAsynResult iar)
{
Socket server = (Socket) iar.AsyncState;
Socket client = server.EndAccep t (iar);
Thread.CurrentT hread.Name = "TCP Accepted on #" +
client.RemoteEn dPoint.ToString ()
...
}
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! 5 6018
The thread running your callback is a thread pool thread. So it could be
the same thread pool thread each time or a different one depending on how
the thread pool threads are being used by the application. So naming the
thread has not much value I think. Moreover, IMO, I don't find using async
Accept very usefull. I would just do accepts on a dedicated thread in your
server listen loop. Then use async reads and writes if you want.
--
William Stacey, MVP http://mvp.support.microsoft.com
"Droopy Toon" <dr********@ibe lgique.com> wrote in message
news:eK******** ******@TK2MSFTN GP11.phx.gbl... 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" threads. I named the thread (see sample code below) in Accept callback started by BeginAccept but all connections accepted run in a thread that has the same name ! So, even a new thread is not started by BeginAccept, even my naming is wrong.
Thanks in advance for your help.
code:
.. Socket server = new Socket (AddressFamily. InterNetwork, SocketType.Stre am, Protocol.Tcp); .. server.BeginAcc ept (new AsyncCallback (AcceptConnecti on), server); ..
void AcceptConnectio n (IAsynResult iar) { Socket server = (Socket) iar.AsyncState; Socket client = server.EndAccep t (iar); Thread.CurrentT hread.Name = "TCP Accepted on #" + client.RemoteEn dPoint.ToString () .. }
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! Moreover, IMO, I don't find using async Accept very usefull. I would just do accepts on a dedicated thread in your server listen loop.
That's right, it gives also better berformance.
Async doesn't mean that all the time you get best performance, always check
speeds and use sync and async in mixed mode.
"William Stacey [MVP]" <st***********@ mvps.org> wrote in message
news:em******** ******@TK2MSFTN GP12.phx.gbl... The thread running your callback is a thread pool thread. So it could be the same thread pool thread each time or a different one depending on how the thread pool threads are being used by the application. So naming the thread has not much value I think. Moreover, IMO, I don't find using async Accept very usefull. I would just do accepts on a dedicated thread in your server listen loop. Then use async reads and writes if you want.
-- William Stacey, MVP http://mvp.support.microsoft.com
"Droopy Toon" <dr********@ibe lgique.com> wrote in message news:eK******** ******@TK2MSFTN GP11.phx.gbl... 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" threads. I named the thread (see sample code below) in Accept callback started by BeginAccept but all connections accepted run in a thread that has the same name ! So, even a new thread is not started by BeginAccept, even my naming is wrong.
Thanks in advance for your help.
code:
.. Socket server = new Socket (AddressFamily. InterNetwork, SocketType.Stre am, Protocol.Tcp); .. server.BeginAcc ept (new AsyncCallback (AcceptConnecti on), server); ..
void AcceptConnectio n (IAsynResult iar) { Socket server = (Socket) iar.AsyncState; Socket client = server.EndAccep t (iar); Thread.CurrentT hread.Name = "TCP Accepted on #" + client.RemoteEn dPoint.ToString () .. }
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
OK I understand.
I should have very few concurrent connections so may be I should not use
async mode and handle all threads by myself.
So, I can name all threads.
I named my threads because my logging is prefixed with the time and the
thread name.
Thanks a lot for your help and best wishes for the year 2005.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Why you need to name threads ? I should have very few concurrent connections
In normal desktop pc it can be 50 - 100.
For good exmple code about socket see www.lumisoft.ee mailserver project.
It uses mixed mode sockets, has simple(as possible) well commented c# source
code.
"Droopy Toon" <dr********@ibe lgique.com> wrote in message
news:eZ******** ******@TK2MSFTN GP14.phx.gbl... OK I understand. I should have very few concurrent connections so may be I should not use async mode and handle all threads by myself. So, I can name all threads. I named my threads because my logging is prefixed with the time and the thread name.
Thanks a lot for your help and best wishes for the year 2005.
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
OK thanks I will have a look at this project.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Zunbeltz Izaola |
last post by:
Hi,
I have the following problem.
I'm developing a GUI program (wxPython). This program has to comunicate
(TCP) whit other program that controls a laboratory machine to do a
measurement. I have a dialog box, wiht two buttoms "Start measurement" and
"Stop". "Start" executes a function that do the measurement in the
following way.
|
by: Richard |
last post by:
Hi,
I'm suffering a socket race condition - I think. The code works fine at
full speed on a single CPU machine. However when I run full speed on a 2
Zeon machine the socket drops data on an asynchronous receive. If I slow a
connected client down by step debugging or putting Thread.Sleep() calls
between sends then the code works on the Zeon machine.
Below is pseudo code that removes all error checking, try catch, business
logic, and...
|
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 what
they were doing could take a look at my code and tell me where and why
I'm going wrong.
Any suggestions of groups or forums?
|
by: taskswap |
last post by:
I have a legacy application written in C that I'm trying to convert to
C#. It processes a very large amount of data from many clients
(actually, upstream servers - this is a mux) simultaneously.
I've read through what must be dozens of ways to do socket
communication in C#, and it seems they all devolve into three basic
options - Socket.Select, IOCP through a native interface, and
Asynchronous callbacks. I'm fine using Asynchronous...
|
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 there is a problem with the
connection.
I need to know which client has sent the incoming data as each client has
its own buffer on my "server" app.
I am using the standard asynch socket code from MSDN to listen for
connections and they...
| |
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 number of different types of data coming in. I have a
databuffer for each type of data coming in.
|
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 client and asynchronous socket
server example code provided in the .NET framework developers guide is a
great start but I have not dealt with sockets before and I am struggling with
something.
From what I can tell the sample server code ...
|
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 supernode.
Everything I have written works fine sending and receiving
uncompressed data. But now I want to implement compression using the
deflate algorithm as the Gnutella protocol accepts:
Accept-Encoding: deflate
Content-Encoding: deflate
in the...
|
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 site, which is actually
for sending strings. I tried to adapt this code so that the client
sends an image instead of a string. However, there is something wrong
on the server side (i guess)...
The server starts listening, the client starts sending...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |