I'll keep it short and simple. Take a look at my source.The following code never runs (under "while (server.Pending == true)"):Code:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net.Sockets; using System.Net; namespace EDOLOGGER_SERVER { public partial class Form1 : Form { TcpListener server; int port = 8888; IPAddress IP = IPAddress.Parse("192.168.1.114"); string n = Environment.NewLine; public void start() { try { textBox1.Text += "in start()" + n; server = new TcpListener(IP, port); server.Start(); } catch (System.Exception e) { textBox1.Text += "EXCEPTION: " + e + n; } } public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { textBox1.Text += "Before start()" + n; start(); textBox1.Text += "After start()" + n; while (server.Pending() == true) { try { textBox1.Text += "Listening for request on " + IP + ":" + port; TcpClient client = server.AcceptTcpClient(); textBox1.Text += "Connection accepted" + n; } catch (System.Exception ex) { textBox1.Text += ex + n; } } } } }
My best guess is that I'm using server.Pending incorrectly, but don't know how to correct that. Thanks in advance"Listening for request on " + IP + ":" + port;
"Connection accepted" + n;


Reply With Quote

Bookmarks