首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

帮忙看看这个程序,一点连接就没响应2

2012-12-17 
求助:帮忙看看这个程序,一点连接就没响应2//线程运行机制public void run( ){while(true){try{sout.writeC

求助:帮忙看看这个程序,一点连接就没响应2
//线程运行机制
public void run( )
{
while(true)
{
try
{
sout.writeChars( textBox_send.get_Text( )) ;
//将缓冲区内容向输出流发送
if( send )
sout.flush() ;
}
catch( Exception e )
{
MessageBox.Show( e.ToString( )) ;
}
}
}

//析构方法
public void finalize( )
{
try
{
//停止ServerSocket服务
server.close( ) ;
}
catch( IOException e )
{
MessageBox.Show( e.ToString( )) ;
}
}

public ServerSocketForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/**
 * Clean up any resources being used.
 */
protected void Dispose(boolean disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
super.Dispose(disposing);
}

#region Windows Form Designer generated code
/**
 * Required method for Designer support - do not modify
 * the contents of this method with the code editor.
 */
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button_send = new System.Windows.Forms.Button();
this.button_link = new System.Windows.Forms.Button();
this.checkBox_ME = new System.Windows.Forms.CheckBox();
this.checkBox_DME = new System.Windows.Forms.CheckBox();
this.button_unlink = new System.Windows.Forms.Button();
this.button_close = new System.Windows.Forms.Button();
this.textBox_send = new System.Windows.Forms.TextBox();
this.textBox_receive = new System.Windows.Forms.TextBox();
this.SuspendLayout();
// 
// label1
// 
this.label1.set_Location(new System.Drawing.Point(8, 16));
this.label1.set_Name("label1");
this.label1.set_Size(new System.Drawing.Size(128, 23));
this.label1.set_TabIndex(0);
this.label1.set_Text("输入发送数据(二进制)");
// 
// label2
// 
this.label2.set_Location(new System.Drawing.Point(8, 152));
this.label2.set_Name("label2");
this.label2.set_Size(new System.Drawing.Size(56, 23));
this.label2.set_TabIndex(1);
this.label2.set_Text("返回信息");
// 
// button_send
// 
this.button_send.set_Location(new System.Drawing.Point(216, 112));
this.button_send.set_Name("button_send");
this.button_send.set_TabIndex(6);
this.button_send.set_Text("发送");
this.button_send.add_Click( new System.EventHandler(this.button_send_Click) );
// 
// button_link
// 
this.button_link.set_Location(new System.Drawing.Point(8, 112));
this.button_link.set_Name("button_link");
this.button_link.set_TabIndex(7);
this.button_link.set_Text("建立连接");
this.button_link.add_Click( new System.EventHandler(this.button_link_Click) );
// 


// checkBox_ME
// 
this.checkBox_ME.set_Location(new System.Drawing.Point(8, 48));
this.checkBox_ME.set_Name("checkBox_ME");
this.checkBox_ME.set_Size(new System.Drawing.Size(128, 24));
this.checkBox_ME.set_TabIndex(8);
this.checkBox_ME.set_Text("曼彻斯特编码发送");
// 
// checkBox_DME
// 
this.checkBox_DME.set_Location(new System.Drawing.Point(8, 80));
this.checkBox_DME.set_Name("checkBox_DME");
this.checkBox_DME.set_Size(new System.Drawing.Size(152, 24));
this.checkBox_DME.set_TabIndex(9);
this.checkBox_DME.set_Text("差分曼彻斯特编码发送");
// 
// button_unlink
// 
this.button_unlink.set_Location(new System.Drawing.Point(112, 112));
this.button_unlink.set_Name("button_unlink");
this.button_unlink.set_TabIndex(11);
this.button_unlink.set_Text("断开连接");
this.button_unlink.add_Click( new System.EventHandler(this.button_unlink_Click) );
// 
// button_close
// 
this.button_close.set_Location(new System.Drawing.Point(320, 112));
this.button_close.set_Name("button_close");
this.button_close.set_TabIndex(12);
this.button_close.set_Text("关闭");
this.button_close.add_Click( new System.EventHandler(this.button_close_Click) );
// 
// textBox_send
// 
this.textBox_send.set_Location(new System.Drawing.Point(168, 16));
this.textBox_send.set_Multiline(true);
this.textBox_send.set_Name("textBox_send");
this.textBox_send.set_ScrollBars(System.Windows.Forms.ScrollBars.Vertical);
this.textBox_send.set_Size(new System.Drawing.Size(368, 80));
this.textBox_send.set_TabIndex(13);
this.textBox_send.set_Text("");
// 
// textBox_receive
// 
this.textBox_receive.set_Location(new System.Drawing.Point(80, 152));
this.textBox_receive.set_Multiline(true);
this.textBox_receive.set_Name("textBox_receive");
this.textBox_receive.set_ReadOnly(true);
this.textBox_receive.set_ScrollBars(System.Windows.Forms.ScrollBars.Vertical);
this.textBox_receive.set_Size(new System.Drawing.Size(456, 104));
this.textBox_receive.set_TabIndex(14);
this.textBox_receive.set_Text("");
// 
// ServerSocketForm
// 
this.set_AutoScaleBaseSize(new System.Drawing.Size(6, 14));
this.set_ClientSize(new System.Drawing.Size(552, 266));
this.get_Controls().Add(this.textBox_receive);
this.get_Controls().Add(this.textBox_send);
this.get_Controls().Add(this.button_close);
this.get_Controls().Add(this.button_unlink);
this.get_Controls().Add(this.checkBox_DME);
this.get_Controls().Add(this.checkBox_ME);
this.get_Controls().Add(this.button_link);
this.get_Controls().Add(this.button_send);
this.get_Controls().Add(this.label2);
this.get_Controls().Add(this.label1);
this.set_Name("ServerSocketForm");
this.set_StartPosition(System.Windows.Forms.FormStartPosition.CenterScreen);
this.set_Text("ServerSocket");
this.set_TopMost(true);
this.add_Load( new System.EventHandler(this.ServerSocketForm_Load) );
this.ResumeLayout(false);

}
#endregion

/**
 * The main entry point for the application.
 */
/** @attribute System.STAThread() */
public static void main(String[] args) 
{
Application.Run(new ServerSocketForm());
}

private void ServerSocketForm_Load (Object sender, System.EventArgs e)


{
}

private void button_link_Click (Object sender, System.EventArgs e)
{
ServerStart( );
}

private void button_unlink_Click (Object sender, System.EventArgs e)
{
send = false ;
unsend = true ;
}

private void button_send_Click (Object sender, System.EventArgs e)
{
send = true ;
unsend = false ;
}

private void button_close_Click (Object sender, System.EventArgs e)
{
this.Close( ) ;
}
}
[解决办法]
ding
[解决办法]
J#还没了解过,帮你顶上去
[解决办法]
帮up

热点排行