All pastes #2943 Raw Copy code Copy link Edit

TCP Client

public text v1 · immutable
#2943 ·published 2004-12-13 13:20 UTC
rendered paste body
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

using System.Net.Sockets;

namespace TestClient
{
	public class Form1 : System.Windows.Forms.Form
	{
		private System.ComponentModel.Container components = null;
		private Socket			_tcpClient;

		public Form1()
		{
			InitializeComponent();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		private void InitializeComponent()
		{
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 266);
			this.Name = "Form1";
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);

		}
		#endregion

		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			System.Net.IPEndPoint ipep = new System.Net.IPEndPoint
				(System.Net.IPAddress.Parse ("127.0.0.1"), 1414);
			_tcpClient = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
			_tcpClient.Connect (ipep);
		}
	}
}