Start my first Telnet console project tour:
To create a console project: Open vs Program, File = "new =" Project
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118202916609-135413544. PNG "style=" margin:0px;padding:0px;border:none; "/>
First, download SuperSocket dynamic library, there are two main ways to get SuperSocket dynamic library.
1. Add SuperSocket DLL file (SuperSocket.Common.dll, SuperSocket.SocketBase.dll, SuperSocket.SocketEngine.dll) to this project reference, To download the SuperSocket component directly from the official website, the introduction of DLL files is required:
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118203601015-1642831844. PNG "style=" margin:0px;padding:0px;border:none; "/>
2, through NuGet to obtain, I also prefer this way, you can update the component version. (Note: I'm using vs2015 to open nuget directly if you use vs older versions of your classmates need to download NuGet components)
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118204356875-1493101090. PNG "style=" margin:0px;padding:0px;border:none; "/>
Click Browse, enter SuperSocket, check the component installation
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118204511078-935872656. PNG "style=" margin:0px;padding:0px;border:none; "/>
After adding the finished component, you need to be aware of compiling the config file into content, log4net need to use config file.
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118204751281-1514032475. PNG "style=" margin:0px;padding:0px;border:none; "/>
View the introduction of the project overall directory, box red line for the introduction of SuperSocket components and files
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118204841078-892085322. PNG "style=" margin:0px;padding:0px;border:none; "/>
II. Testing Service start and stop using the officially provided boot server code
650) this.width=650; "id=" code_img_closed_5fc6d117-2d23-4079-ad80-114d389b6c49 "class=" code_img_closed "src="/img/ Jia.gif "style=" margin:0px;padding:0px 5px 0px 0px;border:none;vertical-align:middle; "/> telnet service start and shutdown
To run the project:
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118205812484-1866807860. PNG "style=" margin:0px;padding:0px;border:none; "/>
After running successfully can view the debug folder under the logs log trace file, from the log, we can see that the server has been able to start the success, but this is not much use, because we do not handle the customer's link to come in, processing the customer sent over the information. According to the official documentation, we continue to copy the code to refine our program.
Iii. registering client links and processing client-sent information
1, handle the client connection, register the new event processing method
appserver.newsessionconnected + = new Sessionhandler (appserver_newsessionconnected);
2. Send the welcome message to the client in the event handling code
static void Appserver_newsessionconnected (Appsession session)
{
Session. Send ("Welcome to SuperSocket Telnet server!");
}
3. Test with Telnet Client (note: Telnet service must be installed first)
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118210932375-1723518064. PNG "style=" margin:0px;padding:0px;border:none; "/>
When the installation is complete, run the Telnet server first
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118211105171-1055819874. PNG "style=" margin:0px;padding:0px;border:none; "/>
Run the win+r Command window cmd and enter telnet localhost 2017. (2017 is the port that listens in the start program)
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118211219953-486469084. PNG "style=" margin:0px;padding:0px;border:none; "/>
Enter to display the welcome note the client and server side are successfully linked.
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118211327375-384289787. PNG "style=" margin:0px;padding:0px;border:none; "/>
4, processing the information sent by the client, I continue to copy the code
650) this.width=650; "id=" code_img_closed_67c13144-5bc5-4c7b-bf0e-9bc2a026787c "class=" code_img_closed "src="/img/ Jia.gif "style=" margin:0px;padding:0px 5px 0px 0px;border:none;vertical-align:middle; "/> client sends request processing
5. Registration Request Event
650) this.width=650; "id=" code_img_closed_22b9088a-7a66-457a-88d2-802904a92799 "class=" code_img_closed "src="/img/ Jia.gif "style=" margin:0px;padding:0px 5px 0px 0px;border:none;vertical-align:middle; "/> Register client request Events
Operating effect:
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118212654125-401372184. PNG "style=" margin:0px;padding:0px;border:none; "/>
In addition to using the Telnet client, there is a TCP/UDP test tool on the web that can link the server
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118213158593-1570689803. PNG "style=" margin:0px;padding:0px;border:none; "/>
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/662342/201701/662342-20170118213309875-646564491. PNG "style=" margin:0px;padding:0px;border:none; "/>
The SuperSocket framework of today's introductory study is here.
SuperSocket Getting Started (i)-telnet server and client request processing