I haven't worried, emptiness, boring, daze ..., always give yourself something to do, I want to go, decide to use C # to do a POP3, SMTP mail to send and receive components, but no Familiar with the POP3, SMTP protocol, online mad, have a little eyebrow, but there is no way to try these orders, can not be, how can I do? Hey, why don't you do a network information to send and check the gadgets of the received information? This can not only try the POP3, SMTP protocol, but also try ftp, http ..., do it, do it, no need to do it, just see a asynchronous thing, in MSDN. Look, I know a probably, then I will do it, I will do it for a long time, I don't understand it. When I don't move, I will check the information.) The following is awkwardly called "TCP NET DIALOG" "Gadget.
HTTP example
FTP example
POP3 example
SMTP example
The source code using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Net; using System.Net.Sockets; using System.Text;
A summary description of Namespace NetConnect {///
Socket MySocket = New Socket (addressFamily.internetwork, sockettype.stream, protocoltype.tcp); string line = "/ r / n"; // newline, and network data end flag static int recvlength = 1024 * 10; / / Number of bytes per accepted byte [] Recvbf = new byte [recvlength]; string nullstring = system.text.utf8encoding.utf8.getstring (new byte [recvlength]); ///
Public Form1 () {// // Windows Form Designer Support for // InitializeComponent ();
// // Todo: Add any constructor code after INITIALIZEComponent call //}
///
#Region Windows Form Designer Generated Code ///
/// summary> private void InitializeComponent () {this.IPTextBox = new System.Windows.Forms.TextBox (); this.PortTextBox = new System.Windows.Forms.TextBox (); this.ConnectButton = new System. Windows.Forms.Button (); this.inputbox = new system.windows.forms.textbox (); this.sendbutton = new system.windows.forms.Button (); this.label1 = new System.Windows.Forms.Label (); This.Label2 = new system.windows.forms.label (); this.label3 = new system.windows.forms.label (); this.disconnectButton = new system.windows.Forms.Button (); this. ResultTextBox = new System.Windows.Forms.RichTextBox (); this.button1 = new System.Windows.Forms.Button (); this.ExitButton = new System.Windows.Forms.Button (); this.statusBar1 = new System. Windows.forms.statusbar (); this.suspendlayout (); // iptextbox // this.iptextbox.location = new system.drawing.point (40, 8); this.iptextBox.name = "iptextbox"; this .Iptextbox.tabindex = 0; this.iptextbox.text = "192.168.72.193"; // // porttextbox // this.PortTextBox.location = new system.drawing.point (176, 8); this.porttextBox.Name = "porttextbox"; this.porttextbox.size = new system.drawing.size (32, 21) ; this.PortTextBox.TabIndex = 1; this.PortTextBox.Text = "80"; // // ConnectButton // this.ConnectButton.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles .Right); this.ConnectButton.Location = new System.Drawing.Point (224, 8); this.ConnectButton.Name = "ConnectButton"; this.ConnectButton.TabIndex = 2; this.ConnectButton.Text = "Connect";
this.ConnectButton.Click = new System.EventHandler (this.ConnectButton_Click); // // InputBox // this.InputBox.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles. Left) | system.windows.forms.Anchorstyles.right); this.inputbox.location = new system.drawing.point (64, 40); this.inputbox.multiline = true; this.inputbox.name = "inputbox"; THISINPUTBOX.SIZE = New System.drawing.size (232, 104); this.inputbox.tabindex = 3; this.inputbox.text = ""; this.inputbox.keyup = new system.windows.Forms.KeyeventHandler (this.InputBox_KeyUp); // // SendButton // this.SendButton.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); this.SendButton.Location = new System. Drawing.point (312, 48); this.sendButton.Name = "sendbutton"; this.sendButton.Tabindex = 4; this.sendButton.text = "send"; this.sendButton.Click = new system.eventhandler (this .Sendbutton_click; // // label1 // This.Label1.Location = new system.drawing.point (8, 8); this.label1.name = "label1"; this.label1.size = new system.drawing.size (32, 23); this.label1. Tabindex = 7; this.label1.text = "ip"; /// Label2 // this.label2.location = new system.drawing.point (144, 8); this.label2.name = "label2"; this .label2.size = new system.drawing.size (32, 23); this.label2.tabindex = 8; this.label2.text = "port"; /// Label3 // this.label3.Location = new system .Drawing.point (8, 40); this.label3.name = "label3";
This.label3.size = new system.drawing.size (48, 23); this.label3.tabindex = 9; this.label3.text = "message"; // disconnectButton // this.disconnectButton.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); this.DisconnectButton.Location = new System.Drawing.Point (312, 8); this.DisconnectButton.Name = "DisconnectButton"; this .DisconnectButton.TabIndex = 10; this.DisconnectButton.Text = "Disconnect"; this.DisconnectButton.Click = new System.EventHandler (this.DisconnectButton_Click); // // ResultTextBox // this.ResultTextBox.Anchor = ((( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); this.ResultTextBox.Location = new System.drawing.point (8, 160); this.ResulttextBox.Name = "resulttextbox"; this.ResulttextBox.readonly = true; this.ResulttextBox.size = new system.drawing.size (384, 3 12); this.ResulttextBox.tabindex = 11; this.ResulttextBox.text = ""; this.resulttextbox.WordWrap = false; // // button1 // this.button1.ancy = (System.Windows.Forms.Anchorstyles. TOP | System.Windows.Forms.Anchorstyles.right; this.button1.location = new system.drawing.point (312, 80); this.button1.name = "button1"; this.button1.tabindex = 12; this .Button1.text = "clear"; this.button1.click = new system.eventhandler (this.button1_click); // // exitButton // this.exitbutton.Anchor =
(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); this.ExitButton.Location = new System.Drawing.Point (312, 112); this.ExitButton.Name = "ExitButton"; this.ExitButton.TabIndex = 13; this.ExitButton.Text = "Exit"; this.ExitButton.Click = new System.EventHandler (this.ExitButton_Click); // // statusBar1 // this.statusBar1.Location = new System .Drawing.point (0, 477); this.statusbar1.name = "statusbar1"; this.statusbar1.size = new system.drawing.size (400, 16); this.statusbar1.tabindex = 14; this.statusbar1. TEXT = "Programd by xuexplorer mail: xuexplorer@163.com"; // // Form1 // this.autoscalebasesize = new system.drawing.size (6, 14); this.clientsize = new system.drawing.size (400 , 493); this.controls.addrange (new system.windows.forms.control [] {this.statusbar1, this.exitbutton, this.button1, this.Resulttextbox, This.disconnectButton, this.label3, this.label2, this.label1, this.sendbutton, this.inputbox, this.connectButton, this.portTextBox, this.iptextbox}); this.name = "form1"; this.text = "TCP NET DIALOG"; this.ResumeLayout (false);} #ENDREGION
///
///
MySocket.BeginReceive (RecvBF, 0, RecvBF.Length, 0, new System.AsyncCallback (ReceiveMessage), MySocket);}} catch (Exception ex) {this.ResultTextBox.Text = "Connect" IPTextBox.Text ":" PortTextBox.text "unsuccessful" line;}}
///
///
///
///
///
///