public partial class _Default : System.Web.UI.Page { static int SERV_TCP_PORT = 8080; static string SERV_HOST_ADDR = "151.0.23.181"; static IPAddress ipAd = IPAddress.Parse(SERV_HOST_ADDR); protected void Page_Load(object sender, EventArgs e) { Thread t = new Thread(new ThreadStart(ListenData)); t.Start(); } public void ListenData() { TcpListener myList = new TcpListener(ipAd, SERV_TCP_PORT); /* Start Listeneting at the specified port */ myList.Start(); Console.WriteLine("The server is running at port ..." + SERV_TCP_PORT); Console.WriteLine("The local End point is :" + myList.LocalEndpoint); Console.WriteLine("Waiting for a connection....."); Socket socket = myList.AcceptSocket(); Console.WriteLine("Connection accepted from " + socket.RemoteEndPoint); byte[] bytes = new byte[7]; int a = socket.Receive(bytes); Label1.Text = Encoding.ASCII.GetString(bytes).ToString(); // Label1.Text = "xx"; } }
i have tried the above written code but it is not working, throw exception: <pre>Only one usage of each socket address (protocol/network address/port) is normally permitted
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)