I am new to developing Windows services, and I need to build it in C #, which will listen 8080on the data input port , and then analyze it. I found information about System.Net.WebSockets, System.Net.Socketsand third-party libraries such as SuperSocket. Here is an example , but not sure what is going on OnStart()and what goes into the methods of OnStop()my Windows service class. Another example is here , but this also does not apply to the Windows service. For basic Windows service development, here is an MSDN article .
I think this happens in OnStart():
Socket serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
serverSocket.Bind(new IPEndPoint(IPAddress.Any, 8080));
serverSocket.Listen(128);
serverSocket.BeginAccept(null, 0, OnAccept, null);
What would I introduce to OnStop()?
The incoming data stream does not require any authentication. Should I still do the handshake?
Your help is appreciated.
source
share