title: Want a .Net Socket Event Handler for incoming data
body: <p>I'm rewriting an ancient VB6 program in C# (.Net Framework 4.0).    It communicates with a piece of industrial equipment on the factory floor.   VB6 used some old COM-based socket software; I'm using the .Net Socket class.</p>
  
  <p>When I send a message to the equipment I expect a response back so I know to listen for one then.  But the equipment can also send messages <strong>asynchronously</strong> without warning (say, to indicate a failure or problem). So I <strong>always</strong> have to receive those.     So what I'd really like is an event handler that gets called whenever anything comes in from the equipment.</p>
  
  <p>The Socket class seems to use a BeginReceive/EndReceive scheme for receive event handling.   Can I just do a BeginReceive once at the start of my program to define an event-handler for all incoming messages, or do I have to constantly be doing BeginReceive/EndReceive's throughout my program?</p>
  
  <p>Thanks in advance for clarifying the correct way to do this.</p>