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.Text;
namespace WindowsApplication12
{
/// <summary>
/// Descrizione di riepilogo per Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
Socket s;
private System.Windows.Forms.TextBox i;
private System.Windows.Forms.TextBox p;
private System.Windows.Forms.TextBox r;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button3;
/// <summary>
/// Variabile di progettazione necessaria.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Necessario per il supporto di Progettazione Windows Form
//
InitializeComponent();
//
// TODO: aggiungere il codice del costruttore dopo la chiamata a InitializeComponent
//
}
/// <summary>
/// Pulire le risorse in uso.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Codice generato da Progettazione Windows Form
/// <summary>
/// Metodo necessario per il supporto della finestra di progettazione. Non modificare
/// il contenuto del metodo con l'editor di codice.
/// </summary>
private void InitializeComponent()
{
System.Resources.
ResourceManager resources
= new System.Resources.
ResourceManager(typeof(Form1
));
this.
i = new System.
Windows.
Forms.
TextBox();
this.
p = new System.
Windows.
Forms.
TextBox();
this.
r = new System.
Windows.
Forms.
TextBox();
this.
button1 = new System.
Windows.
Forms.
Button();
this.
button3 = new System.
Windows.
Forms.
Button();
this.SuspendLayout();
//
// i
//
this.
i.
Font = new System.Drawing.
Font("Comic Sans MS", 9F,
System.Drawing.
FontStyle.
Bold,
System.Drawing.
GraphicsUnit.
Point,
((System.
Byte)(0
)));
this.i.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(192)), ((System.Byte)(0)));
this.
i.
Location = new System.Drawing.
Point(8, 16
);
this.i.Name = "i";
this.
i.
Size = new System.Drawing.
Size(120, 24
);
this.i.TabIndex = 0;
this.i.Text = "127.0.0.1";
//
// p
//
this.
p.
Font = new System.Drawing.
Font("Comic Sans MS", 9F,
System.Drawing.
FontStyle.
Bold,
System.Drawing.
GraphicsUnit.
Point,
((System.
Byte)(0
)));
this.p.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(192)), ((System.Byte)(0)));
this.
p.
Location = new System.Drawing.
Point(208, 16
);
this.p.Name = "p";
this.
p.
Size = new System.Drawing.
Size(120, 24
);
this.p.TabIndex = 1;
this.p.Text = "411";
//
// r
//
this.
r.
Location = new System.Drawing.
Point(8, 104
);
this.r.Multiline = true;
this.r.Name = "r";
this.
r.
Size = new System.Drawing.
Size(320, 40
);
this.r.TabIndex = 2;
this.r.Text = "";
//
// button1
//
this.
button1.
Font = new System.Drawing.
Font("Comic Sans MS", 9F,
System.Drawing.
FontStyle.
Bold,
System.Drawing.
GraphicsUnit.
Point,
((System.
Byte)(0
)));
this.button1.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(192)), ((System.Byte)(0)));
this.
button1.
Location = new System.Drawing.
Point(8, 224
);
this.button1.Name = "button1";
this.
button1.
Size = new System.Drawing.
Size(88, 32
);
this.button1.TabIndex = 3;
this.button1.Text = "CoNNeTTi";
this.
button1.
Click += new System.
EventHandler(this.
button1_Click);
//
// button3
//
this.
button3.
Font = new System.Drawing.
Font("Comic Sans MS", 9F,
System.Drawing.
FontStyle.
Bold,
System.Drawing.
GraphicsUnit.
Point,
((System.
Byte)(0
)));
this.button3.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(192)), ((System.Byte)(0)));
this.
button3.
Location = new System.Drawing.
Point(240, 224
);
this.button3.Name = "button3";
this.
button3.
Size = new System.Drawing.
Size(96, 32
);
this.button3.TabIndex = 5;
this.button3.Text = "DiSCoNNeTTi";
this.
button3.
Click += new System.
EventHandler(this.
button3_Click);
//
// Form1
//
this.
AutoScaleBaseSize = new System.Drawing.
Size(5, 13
);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.
ClientSize = new System.Drawing.
Size(344, 266
);
this.Controls.Add(this.button3);
this.Controls.Add(this.button1);
this.Controls.Add(this.r);
this.Controls.Add(this.p);
this.Controls.Add(this.i);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = " (¯`·.¡†§å†åÑå Á††åÇk 1.2†¡.·´¯)";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// Il punto di ingresso principale dell'applicazione.
/// </summary>
[STAThread]
static void Main()
{
Application.
Run(new Form1
());
}
private void button1_Click(object sender, System.EventArgs e)
{
r.Text="";
r.AppendText("***CoNNeSSioNe In CoRSo a: "+i.Text+":"+p.Text+"\n");
try
{
r.AppendText("***CoNNeSSo\n");
s
= new Socket
(AddressFamily.
InterNetwork,SocketType.
Stream,ProtocolType.
Tcp);
IPEndPoint iep
= new IPEndPoint
(IPAddress.
Parse(i.
Text),Convert.
ToInt32(p.
Text));
s.Connect(iep);
}
catch{r.AppendText("***IMPoSSiBiLe CoNNeTTeRSi ALL'HoST!\n");}
}
private void button2_Click(object sender, System.EventArgs e)
{
}
private void button3_Click(object sender, System.EventArgs e)
{
}
public void Disconnetti()
{
if(s!=null && s.Connected)
s.Close();
r.AppendText("***DiSCoNNeSSo\n");
}
}
}