none
TCP IP Listener C# Server Problem RRS feed

  • Question

  • hi Kindly advise us . 

    create  TCPIP Listener  in c#  Please provide guide Line .

    1. My Listener Received data and close .
    2.i want server received data and transfer  data to String Variable  or  copy data to text file .
    4.aftter copy string variable value empty
    3. Server received data from multiple  client  currently one client is connected with my server .

    below is my code. 

    public class server
    {
        public static void Main()
        {
            
            try
            {
                IPAddress ipAd = IPAddress.Parse("127.0.0.1");
                // use local m/c IP address, and 
                // use the same in the client
    
                /* Initializes the Listener */
                TcpListener myList = new TcpListener(ipAd, 8001);
    
                /* Start Listeneting at the specified port */
                myList.Start();
    
                Console.WriteLine("The server is running at port 8001...");
                Console.WriteLine("The local End point is  :" +
                                  myList.LocalEndpoint);
                Console.WriteLine("Waiting for a connection.....");
    
                Socket s = myList.AcceptSocket();
                Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);
    
                byte[] b = new byte[256];
                int k = s.Receive(b);
                Console.WriteLine("Recieved...");
                for (int i = 0; i < k; i++)
                    Console.Write(Convert.ToChar(b[i]));
    
                * clean up */
               s.Close();
              myList.Stop();
                Console.ReadLine();
    
            }
            catch (Exception e)
            {
                Console.WriteLine("Error..... " + e.StackTrace);
            }
        }
    
    }
    

     

    Friday, September 18, 2020 5:12 PM

Answers

  • MSDN is for learning how to be a programmer.  The questions MSDN Users respond to are questions about "how does this work" or "why does this work" or "why doesn't this work."

    You've given us some specifications and some sample code which you copied directly from an online example.  For the record, there are already hundreds of online examples that include your specifications.  So you're not looking to program this yourself and you're too lazy to even do much research on the internet before posting your job someplace.

    If you want the whole thing done for you, go find a freelancing site and hire a programmer. 


    Before you can learn anything new you have to learn that there's stuff you don't know.

    • Marked as answer by saqsaqPK Sunday, September 20, 2020 4:15 PM
    Sunday, September 20, 2020 12:54 PM

All replies

  • any update
    Saturday, September 19, 2020 6:58 AM
  • MSDN is for learning how to be a programmer.  The questions MSDN Users respond to are questions about "how does this work" or "why does this work" or "why doesn't this work."

    You've given us some specifications and some sample code which you copied directly from an online example.  For the record, there are already hundreds of online examples that include your specifications.  So you're not looking to program this yourself and you're too lazy to even do much research on the internet before posting your job someplace.

    If you want the whole thing done for you, go find a freelancing site and hire a programmer. 


    Before you can learn anything new you have to learn that there's stuff you don't know.

    • Marked as answer by saqsaqPK Sunday, September 20, 2020 4:15 PM
    Sunday, September 20, 2020 12:54 PM