Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
GeneralRe: FolderBrowser crashes with long paths Pin
Lasome4-Aug-04 5:59
Lasome4-Aug-04 5:59 
GeneralRe: FolderBrowser crashes with long paths Pin
Nick Parker4-Aug-04 6:10
protectorNick Parker4-Aug-04 6:10 
GeneralRe: FolderBrowser crashes with long paths Pin
Heath Stewart4-Aug-04 7:01
protectorHeath Stewart4-Aug-04 7:01 
Generalrun time properties in icon Pin
aberger564-Aug-04 5:33
aberger564-Aug-04 5:33 
GeneralRe: run time properties in icon Pin
Heath Stewart4-Aug-04 5:49
protectorHeath Stewart4-Aug-04 5:49 
GeneralRe: run time properties in icon Pin
Nick Parker4-Aug-04 5:55
protectorNick Parker4-Aug-04 5:55 
GeneralRe: run time properties in icon Pin
aberger564-Aug-04 6:13
aberger564-Aug-04 6:13 
QuestionC# Socket Problem??? Pin
Korjiro4-Aug-04 5:31
Korjiro4-Aug-04 5:31 
Hi all,

I have a program, that is just supposed to open as a server (i.e. listen for connections) and i run it, and it pauses... then i try to move something and the dreaded program not responding error comes up.... I'm new to c# and don't quite understand why this does this. Another side note.. the designer doesnt work now since i added my inner namespace Tito_Network, which handles the networking calls...

here is my code..

<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
namespace WindowsApplication4<br />
{<br />
//inner namespace used to handle network calls via Obtain Client under Action <br />
//tab<br />
	namespace Tito_Network<br />
	{<br />
		using System;<br />
		using System.Text;<br />
		using System.Net;<br />
		using System.Net.Sockets;<br />
		using System.Windows.Forms;<br />
	<br />
		public class Listen<br />
		{<br />
		<br />
			public Listen(TextBox one, TextBox two)		{<br />
				IPAddress ip = IPAddress.Parse("127.0.0.1");<br />
				TcpListener tcp = new TcpListener(ip,2486);<br />
				tcp.Start();<br />
			<br />
				one.Text +="Server Activated...\n";<br />
<br />
				Socket soc_Client = tcp.AcceptSocket();<br />
<br />
				try<br />
				{<br />
					if(soc_Client.Connected)<br />
					{<br />
						while(true)<br />
						{<br />
							one.Text +="Client connected from"+soc_Client.AddressFamily;<br />
						}<br />
					}<br />
				}<br />
				catch(Exception s)<br />
				{<br />
					MessageBox.Show(s.ToString());<br />
				}<br />
			}<br />
		}<br />
	}<br />
<br />
<br />
<br />
<br />
<br />
	/// <summary><br />
	/// Summary description for Form1.<br />
	/// </summary><br />
	public class Form1 : System.Windows.Forms.Form<br />
	{<br />
		#region Private Form Variables<br />
		private System.Windows.Forms.TextBox textBox1;<br />
		private System.Windows.Forms.TextBox textBox2;<br />
		private System.Windows.Forms.MainMenu mainMenu1;<br />
		private System.Windows.Forms.MenuItem menuItem1;<br />
		private System.Windows.Forms.MenuItem menuItem2;<br />
		private System.Windows.Forms.MenuItem menuItem3;<br />
		private System.Windows.Forms.MenuItem menuItem4;<br />
		private System.Windows.Forms.MenuItem menuItem5;<br />
		/// <summary><br />
		/// Required designer variable.<br />
		/// </summary><br />
		private System.ComponentModel.Container components = null;<br />
		#endregion <br />
<br />
		#region Initialization and Disposal<br />
		public Form1()<br />
		{<br />
			//<br />
			// Required for Windows Form Designer support<br />
			//<br />
			InitializeComponent();<br />
<br />
			//<br />
			// TODO: Add any constructor code after InitializeComponent call<br />
			//<br />
		}<br />
<br />
		/// <summary><br />
		/// Clean up any resources being used.<br />
		/// </summary><br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			if( disposing )<br />
			{<br />
				if (components != null) <br />
				{<br />
					components.Dispose();<br />
				}<br />
			}<br />
			base.Dispose( disposing );<br />
		}<br />
		#endregion <br />
<br />
		#region Windows Form Designer generated code<br />
		/// <summary><br />
		/// Required method for Designer support - do not modify<br />
		/// the contents of this method with the code editor.<br />
		/// </summary><br />
		private void InitializeComponent()<br />
		{<br />
			this.textBox1 = new System.Windows.Forms.TextBox();<br />
			this.textBox2 = new System.Windows.Forms.TextBox();<br />
			this.mainMenu1 = new System.Windows.Forms.MainMenu();<br />
			this.menuItem1 = new System.Windows.Forms.MenuItem();<br />
			this.menuItem2 = new System.Windows.Forms.MenuItem();<br />
			this.menuItem3 = new System.Windows.Forms.MenuItem();<br />
			this.menuItem4 = new System.Windows.Forms.MenuItem();<br />
			this.menuItem5 = new System.Windows.Forms.MenuItem();<br />
			this.SuspendLayout();<br />
			// <br />
			// textBox1<br />
			// <br />
			this.textBox1.AutoSize = false;<br />
			this.textBox1.BackColor = System.Drawing.SystemColors.WindowText;<br />
			this.textBox1.ForeColor = System.Drawing.Color.Lime;<br />
			this.textBox1.Location = new System.Drawing.Point(16, 184);<br />
			this.textBox1.Name = "textBox1";<br />
			this.textBox1.ReadOnly = true;<br />
			this.textBox1.Size = new System.Drawing.Size(384, 136);<br />
			this.textBox1.TabIndex = 0;<br />
			this.textBox1.Text = "textBox1";<br />
			// <br />
			// textBox2<br />
			// <br />
			this.textBox2.AutoSize = false;<br />
			this.textBox2.BackColor = System.Drawing.Color.Black;<br />
			this.textBox2.ForeColor = System.Drawing.Color.Lime;<br />
			this.textBox2.Location = new System.Drawing.Point(472, 184);<br />
			this.textBox2.Name = "textBox2";<br />
			this.textBox2.ReadOnly = true;<br />
			this.textBox2.Size = new System.Drawing.Size(80, 136);<br />
			this.textBox2.TabIndex = 1;<br />
			this.textBox2.Text = "textBox2";<br />
			// <br />
			// mainMenu1<br />
			// <br />
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {<br />
																					  this.menuItem1,<br />
																					  this.menuItem3});<br />
			// <br />
			// menuItem1<br />
			// <br />
			this.menuItem1.Index = 0;<br />
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {<br />
																					  this.menuItem2});<br />
			this.menuItem1.Text = "File";<br />
			// <br />
			// menuItem2<br />
			// <br />
			this.menuItem2.Index = 0;<br />
			this.menuItem2.Text = "Quit";<br />
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);<br />
			// <br />
			// menuItem3<br />
			// <br />
			this.menuItem3.Index = 1;<br />
			this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {<br />
																					  this.menuItem4,<br />
																					  this.menuItem5});<br />
			this.menuItem3.Text = "Connections";<br />
			// <br />
			// menuItem4<br />
			// <br />
			this.menuItem4.Index = 0;<br />
			this.menuItem4.Text = "Obtain Clients";<br />
			this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);<br />
			// <br />
			// menuItem5<br />
			// <br />
			this.menuItem5.Index = 1;<br />
			this.menuItem5.Text = "Deactivate Client";<br />
			// <br />
			// Form1<br />
			// <br />
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
			this.ClientSize = new System.Drawing.Size(576, 333);<br />
			this.Controls.Add(this.textBox2);<br />
			this.Controls.Add(this.textBox1);<br />
			this.Menu = this.mainMenu1;<br />
			this.Name = "Form1";<br />
			this.Text = "Tito v1.0";<br />
			this.ResumeLayout(false);<br />
<br />
		}<br />
		#endregion<br />
<br />
<br />
		#region App Main<br />
		/// <summary><br />
		/// The main entry point for the application.<br />
		/// </summary><br />
		[STAThread]<br />
		static void Main() <br />
		{<br />
			Application.Run(new Form1());<br />
		}<br />
		#endregion<br />
<br />
		#region Event Handlers<br />
		private void menuItem2_Click(object sender, System.EventArgs e)<br />
		{<br />
			if(MessageBox.Show("Are you sure you want to quit?","Tito v1.0",<br />
				MessageBoxButtons.OKCancel,MessageBoxIcon.Warning)== DialogResult.OK)<br />
					{<br />
				Application.Exit();<br />
			}<br />
		}<br />
		<br />
<br />
		private void menuItem4_Click(object sender, System.EventArgs e)<br />
		{<br />
			Tito_Network.Listen l = new Tito_Network.Listen(textBox1,textBox2);<br />
		}<br />
		#endregion <br />
		<br />
	}<br />
}<br />
<br />
<br />

AnswerRe: C# Socket Problem??? Pin
Heath Stewart4-Aug-04 5:52
protectorHeath Stewart4-Aug-04 5:52 
GeneralThumbnail Speed Increase Pin
Gambit_Sunob4-Aug-04 4:27
Gambit_Sunob4-Aug-04 4:27 
GeneralRe: Thumbnail Speed Increase Pin
Nigel Savidge4-Aug-04 5:00
Nigel Savidge4-Aug-04 5:00 
GeneralRe: Thumbnail Speed Increase Pin
Gambit_Sunob4-Aug-04 5:18
Gambit_Sunob4-Aug-04 5:18 
GeneralRe: Thumbnail Speed Increase Pin
Nigel Savidge4-Aug-04 6:16
Nigel Savidge4-Aug-04 6:16 
GeneralRe: Thumbnail Speed Increase Pin
Nick Parker4-Aug-04 5:36
protectorNick Parker4-Aug-04 5:36 
GeneralWeb app not calling Application_End Pin
IrishSonic4-Aug-04 3:46
IrishSonic4-Aug-04 3:46 
GeneralRe: Web app not calling Application_End Pin
leppie4-Aug-04 4:05
leppie4-Aug-04 4:05 
GeneralRe: Web app not calling Application_End Pin
Heath Stewart4-Aug-04 5:20
protectorHeath Stewart4-Aug-04 5:20 
GeneralToday screen component Pin
memsharp4-Aug-04 2:10
memsharp4-Aug-04 2:10 
GeneralRe: Today screen component Pin
Nick Parker4-Aug-04 4:19
protectorNick Parker4-Aug-04 4:19 
GeneralRe: Today screen component Pin
Heath Stewart4-Aug-04 5:12
protectorHeath Stewart4-Aug-04 5:12 
GeneralRe: Today screen component Pin
Nick Parker4-Aug-04 5:42
protectorNick Parker4-Aug-04 5:42 
GeneralRe: Today screen component Pin
Heath Stewart4-Aug-04 5:14
protectorHeath Stewart4-Aug-04 5:14 
GeneralRe: Today screen component Pin
memsharp7-Aug-04 21:48
memsharp7-Aug-04 21:48 
Generaluninstall in pocket pc Pin
memsharp4-Aug-04 2:05
memsharp4-Aug-04 2:05 
GeneralRe: uninstall in pocket pc Pin
Heath Stewart4-Aug-04 5:55
protectorHeath Stewart4-Aug-04 5:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.