Hi,
How do I pool my socket to see if there is any message pending?
I don't want to use timers because they are multithreaded and it break
the linearity of my messages. (incoming message are numbered and it is
important to keep the order)
Can I add a handler to the socket? So it could react by itself when
there is pending data? Something like that the winsock (in VB6) was doing.
Thank you. 4 1731
In article <dcaOc.118392$R f.22568@edtnps8 4>, User wrote: Hi,
How do I pool my socket to see if there is any message pending?
I don't want to use timers because they are multithreaded and it break the linearity of my messages. (incoming message are numbered and it is important to keep the order)
Can I add a handler to the socket? So it could react by itself when there is pending data? Something like that the winsock (in VB6) was doing.
Thank you.
The absolute best way to do this would most likely be to use the asnyc
methods of the socket class (BeginXXXX). The socket will then fire a
callback when data is received.
You could also use the Poll method on the socket to determine if there
is data. You can also use Socket.Select along with Receive with the
Peek flag to determine the socket state...
There are a number of ways that you can accomplish what you're asking,
but the Asnyc methods are usually the most efficient.
--
Tom Shelton [MVP]
Thank you Tom,
I have another question. I haven't use this async socket yet, but I'll
read on it. Right now, I am using a timer control to pool over the
socket.pending to see if there is new data to process. The timer is
running all day long.
Does the async socket, once started, will pool the socket as long as it
is not stopped? I mean, I start it once and will run as the same way I
am using the timer control right now?
Thank you.
Tom Shelton wrote: In article <dcaOc.118392$R f.22568@edtnps8 4>, User wrote:
Hi,
How do I pool my socket to see if there is any message pending?
I don't want to use timers because they are multithreaded and it break the linearity of my messages. (incoming message are numbered and it is important to keep the order)
Can I add a handler to the socket? So it could react by itself when there is pending data? Something like that the winsock (in VB6) was doing.
Thank you.
The absolute best way to do this would most likely be to use the asnyc methods of the socket class (BeginXXXX). The socket will then fire a callback when data is received.
You could also use the Poll method on the socket to determine if there is data. You can also use Socket.Select along with Receive with the Peek flag to determine the socket state...
There are a number of ways that you can accomplish what you're asking, but the Asnyc methods are usually the most efficient.
On Fri, 30 Jul 2004 12:36:13 GMT, User wrote: Thank you Tom,
I have another question. I haven't use this async socket yet, but I'll read on it. Right now, I am using a timer control to pool over the socket.pending to see if there is new data to process. The timer is running all day long.
Does the async socket, once started, will pool the socket as long as it is not stopped? I mean, I start it once and will run as the same way I am using the timer control right now?
Thank you.
Basically, once you begin the async operation, it will continue until the
socket is closed - or the call back is fired. Once it is fired, you need
to call the async method again... So just for a quick psuedo code example:
begin serverfunc
socket.bind
socket.listen
while (running)
manualreseteven t.reset
socket.beginacc ept
manualreseteven t.waitone
wend
end serverfunc
begin acceptfunc
' get socket object
client = get_from_async_ object
' signal server thread to continue
manualreseteven t.set
client.beginrea d
end acceptfunc
begin readfunc
' do read stuff
' send a reply
client.beginsen d
end readfunc
begin sendfunc
if sent client.beginrea d
end sendfunc
etc, etc...
There are some good articles on msdn (this should get you in the correct
location): http://msdn.microsoft.com/library/de...rverSocket.asp
There is a little more code involved in using the async methods, but they
are the most scalable and efficient.
--
Tom Shelton [MVP]
That is very interesting Tom, I red the article on MSDN, I got to use it.
Thank you very much.
Tom Shelton wrote: On Fri, 30 Jul 2004 12:36:13 GMT, User wrote:
Thank you Tom,
I have another question. I haven't use this async socket yet, but I'll read on it. Right now, I am using a timer control to pool over the socket.pendin g to see if there is new data to process. The timer is running all day long.
Does the async socket, once started, will pool the socket as long as it is not stopped? I mean, I start it once and will run as the same way I am using the timer control right now?
Thank you.
Basically, once you begin the async operation, it will continue until the socket is closed - or the call back is fired. Once it is fired, you need to call the async method again... So just for a quick psuedo code example:
begin serverfunc socket.bind socket.listen while (running) manualreseteven t.reset socket.beginacc ept manualreseteven t.waitone wend end serverfunc
begin acceptfunc ' get socket object client = get_from_async_ object
' signal server thread to continue manualreseteven t.set
client.beginrea d end acceptfunc
begin readfunc ' do read stuff
' send a reply client.beginsen d end readfunc
begin sendfunc if sent client.beginrea d end sendfunc
etc, etc...
There are some good articles on msdn (this should get you in the correct location):
http://msdn.microsoft.com/library/de...rverSocket.asp
There is a little more code involved in using the async methods, but they are the most scalable and efficient. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kieran Benton |
last post by:
Hello,
I'm currently in the tail end process of developing a high scalability
server for my employer. Essentially it receives short socket based
connections with an ASCII message, parses that message, does some
processing and then sends out a string reply on the same connection.
I'm using the asynchrounous IO completion port based socket methods in
..NET 2.0 to handle the comms side of things (giving extremely good
performance) and the...
|
by: david.kao |
last post by:
Hi All:
I am creating a COM+ Pool object in C#. I set up the following attributes:
JIT (true),Pool size; and at the end of each public method I called
ContextUtil.DeactivateOnReturn=true to set DONE flag; and also I override
CanBeBooled method to true.
In my calling program in C#, first of all I am using NEW to create a object,
then I call the method then I call dispose.
|
by: Abhishek Srivastava |
last post by:
Hello All,
In IIS 6.0 We have a concept of worker processes and application pools.
As I understand it, we can have multiple worker process per appliction
pool. Each worker process is dedicated to a pool. If I assign only one
application to a applicaton pool and have multiple worker processes
assigned to that pool. Will my application be processed by many worker
processes?
|
by: User |
last post by:
Hi,
How do I pool my socket to see if there is any message pending?
I don't want to use timers because they are multithreaded and it break
the linearity of my messages. (incoming message are numbered and it is
important to keep the order)
Can I add a handler to the socket? So it could react by itself when
there is pending data? Something like that the winsock (in VB6) was doing.
|
by: Lee Greco |
last post by:
I'm looking for some advice on how to proceed.
Here's the scenario:
I've got to develop a high availability VB.Net web service that basically
acts as a middle man between the web service clients and a third party data
provider. The third party data provider is accessed over a well defined TCP
interface. The third party data server can accept about 25 concurrent TCP
connections from the same client.
| |
by: JoeSep |
last post by:
Hi!
Is it correct/safe to define a connection pool in the string
"sqlConnectionString" of the "sessionState" section of Web.config?
- The application is developed using AspNet 1.1 in a Windows Server 2003.
- The AspState DB is defined in a Sql Server 2000 DB on another server.
I have added this definition to the Web.config file:
<sessionState
mode="SQLServer"
|
by: roni schuetz |
last post by:
since a few day's i'm running around the problem that I stocked with a
change i need to do. hopefully somebody here can give me a tipp which
will be usefull to solve my problem.
I'm using a thread-pool within my WebSite which done some requests to
several interfaces the readed data will be added to the cache. This
operations consumes much CPU and I want to have this outside my
website so i decided to change the flow.
It should looks...
|
by: mackenzie |
last post by:
Hello,
I am looking for a little bit of help. I am trying to create a
dynamically allocated object which contains one or more objects of
type boost::pool<>. I get a compiler error when an object of this type
is contained in my class and am not sure why. To be honest I have a
little but not a lot of experience with templates and it could simply
be obvious to a more experienced template user; however, the answer
escapes me.
Here is a...
|
by: =?GB2312?B?0rvK18qr?= |
last post by:
Hi all,
Recently I had a new coworker. There is some dispute between us.
The last company he worked for has a special networking programming
model. They split the business logic into different modules, and have
a dedicated thread for the each module. Modules exchanged info
through a in-memory message queue.
In my opinion, such a model means very complicated asynchronous
|
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: 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |