none
socket programming RRS feed

  • Question

  • Hi i was wondering is there any event based socket class in c# or not, i recently worked with serial ports and in serial port class there were events for getting message and also it is possible to use threads and infinite loop for getting messages, so i thought that would be really great if we can use the same approach of getting messages with an event in sockets instead of making infinite loop in a thread but when i read the documentation of socket class i find out that it contains no event, so i was wondering for an alternative solution, and also why there is no event in socket class??


    Friday, November 10, 2017 8:02 PM

Answers

  • Hello,

     Windows is designed as Event driven. Read info at link below;

     

     https://msdn.microsoft.com/en-us/library/windows/desktop/ms644927(v=vs.85).aspx#system_defined

     

     Hope this helps :)


    • Edited by User3DX Saturday, November 11, 2017 12:50 AM spelling
    • Marked as answer by F_M_L Thursday, February 15, 2018 12:36 AM
    Friday, November 10, 2017 11:09 PM

All replies

  • Hello,

     Windows is designed as Event driven. Read info at link below;

     

     https://msdn.microsoft.com/en-us/library/windows/desktop/ms644927(v=vs.85).aspx#system_defined

     

     Hope this helps :)


    • Edited by User3DX Saturday, November 11, 2017 12:50 AM spelling
    • Marked as answer by F_M_L Thursday, February 15, 2018 12:36 AM
    Friday, November 10, 2017 11:09 PM
  • Consider using Windows Communication Foundation (WCF) as in Conceptual Overview. Sockets are one of many protocols that can be used with WCF. If you learn WCF then you can use other protocols without the need to learn specifics of them.


    Sam Hobbs
    SimpleSamples.Info

    • Proposed as answer by Fei HuModerator Wednesday, November 15, 2017 10:24 AM
    Saturday, November 11, 2017 9:59 PM