![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
|
Hi, I have a client and server application running on a local host, what I am trying to do is ...The client will send an IP address, and City to the server and the will compare this info to the database (MS access) and then send a response back to client if the data are in the database or not. for some reason my client just exit right after connect and I can not figure it out so far. My query works fine. I think I just a set of different eyes to look at it. I know it is long, but I dont know what to do. Here is the Database (Fake data): IP_Address City 127.12.12.3 Dallas 127.3.2.3 Oak Cliff 127.0.0.9 Garland 124.125.12.3 Plano 132.25.6.9 Grand Praire Here is my Client using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Net.Sockets; using System.Threading; using System.IO; namespace SimSocClient { /// <summary /// Summary description for Form1. /// </summary public class Client : 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.TextBox textBox2; private System.Windows.Forms.Button button1; private System.Windows.Forms.TextBox textBox3; /// <summary /// Required designer variable. /// </summary private NetworkStream output; private BinaryWriter writer; private BinaryReader reader; private string message = ""; //private string message1 = ""; private string user_IP = ""; private string user_city = ""; private Thread readThread; private System.ComponentModel.Container components = null; public Client() { // // Required for Windows Form Designer support // InitializeComponent(); readThread = new Thread(new ThreadStart (RunClient)); readThread.Start(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary /// Clean up any resources being used. /// </summary protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </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.textBox2 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.textBox3 = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // label1 // this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label1.Location = new System.Drawing.Point(8, 32); this.label1.Name = "label1"; this.label1.TabIndex = 0; this.label1.Text = "IP Address"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(128, 32); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(176, 20); this.textBox1.TabIndex = 1; this.textBox1.Text = ""; // // label2 // this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label2.Location = new System.Drawing.Point(8, 88); this.label2.Name = "label2"; this.label2.TabIndex = 2; this.label2.Text = "City"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // textBox2 // this.textBox2.Location = new System.Drawing.Point(128, 88); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(176, 20); this.textBox2.TabIndex = 3; this.textBox2.Text = ""; // // button1 // this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button1.Location = new System.Drawing.Point(328, 56); this.button1.Name = "button1"; this.button1.TabIndex = 4; this.button1.Text = "Verify"; this.button1.Click += new System.EventHandler(this.button1_Click); // // textBox3 // this.textBox3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.textBox3.Location = new System.Drawing.Point(16, 136); this.textBox3.Multiline = true; this.textBox3.Name = "textBox3"; this.textBox3.Size = new System.Drawing.Size(384, 208); this.textBox3.TabIndex = 5; this.textBox3.Text = ""; // // Client // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(424, 366); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.textBox3, this.button1, this.textBox2, this.label2, this.textBox1, this.label1}); this.Name = "Client"; this.Text = "Simple Socket Client"; this.ResumeLayout(false); } #endregion /// <summary /// The main entry point for the application. /// </summary [STAThread] static void Main() |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |