请帮忙看看这个程序为什么出错?
这是一个SMTP服务器程序,编绎的时候出现两种错误:1.“名称'newClient'在类或命名空间'accep_so.Form2'中不存在。2.找不到类型或命名空间名称'(是否缺少using指令或程序集引用?)
请各位高手帮忙看一下,谢谢!
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.Threading;
using System.IO;
namespace accep_so
{
/// <summary>
/// Form2 的摘要说明。
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.RichTextBox richTextBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private bool control =false;
Thread thread;
private int port;
private TcpListener listener;
public Form2()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(0, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 23);
this.label1.TabIndex = 0;
this.label1.Text = "监听端口:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(64, 8);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 1;
this.textBox1.Text = "textBox1";
//
// label2
//
this.label2.Location = new System.Drawing.Point(0, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 2;
this.label2.Text = "客户信息:";
//
// button1
//
this.button1.Location = new System.Drawing.Point(64, 248);
this.button1.Name = "button1";
this.button1.TabIndex = 5;
this.button1.Text = "开始服务";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(168, 248);
this.button2.Name = "button2";
this.button2.TabIndex = 6;
this.button2.Text = "关闭服务";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(64, 40);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(224, 200);
this.richTextBox1.TabIndex = 7;
this.richTextBox1.Text = "richTextBox1";
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.richTextBox1,
this.button2,
this.button1,
this.label2,
this.textBox1,
this.label1});
this.Name = "Form2";
this.Text = "Form2";
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form2());
}
private void button1_Click(object sender, System.EventArgs e)
{
try
{
port =Int32.Parse(textBox1.Text);
}
catch
{
MessageBox.Show("您输入的格式不对!请输入正整数。");
}
try
{
listener=new TcpListener(port);
listener.Start();
thread=new Thread(new ThreadStart(recieve));
thread.Start();
}
catch(Exception ee){MessageBox.Show(ee.Message);}
}
private void Form2_Load(object sender, System.EventArgs e)
{
}
private void button2_Click(object sender, System.EventArgs e)
{
try
{
listener.Stop();
}
catch(Exception ee){MessageBox.Show(ee.Message);}
}
private void recieve()
{
while(true)
{
newClient=listener.AcceptSocket();
if(newClient.Connected)
{
Thread thread=new Thread(new ThreadStart(round));
thread.Start();
}
}
}
private void round()
{
bool mailfrom=false;
bool rcptto=false;
bool getMail=false;
StreamWriter mail=null;
int queue=0;
string commString= null;
string bigComm=null;
string command=null;
string parameter=null;
string hostName=null;
string mailbox=null;
NetworkStream netStream=new NetworkStream(newClient);
string from=null;
sendFeedback(ref netStream,"220 SMTP Server Ready!");
while(true)
{
//接受信息++++++
if(getMail==false)
{
commString= readCommand(ref netStream);
bigComm=bigCommand (commString);
command=splitCommand(bigComm);
parameter=splitParameter(bigComm);
command=command.ToLower();
parameter=parameter.ToLower();
hostName=Dns.GetHostName();
richTextBox1.AppendText("command:"+command+" "+"parameter:"+parameter+"\r\n");
}
if(command=="helo")
{
try
{
sendFeedback(ref netStream,"250 "+hostName);
mailfrom=false;
rcptto=false;
}
catch
{