Listening for Data on a TCP Port RRS feed

  • Question

  • I've done this for UDP and it was straight forward... now I'm trying to do this on TCP port 9600.

    I have a service that's running on our live servers. Every .1 to 3000 seconds our server will get hit with a snippet of data on this TCP port. I need to have a listener in place to get that data.

    now I could have multiple incoming streams in one given time, so I am doing this all on threads.

    For UDP I'd do something like:

            private void GetEarthLinkData()
                byte[] ddata;
                while (true)
                        IPEndPoint remoteIPEndpoint = new IPEndPoint(IPAddress.Any, _udpEarthLinkPort);
                        ddata = _udpEarthLinkListener.Receive(ref remoteIPEndpoint);
                        EarthLinkDataArival(remoteIPEndpoint.Address.ToString(), ddata);

                    catch (Exception e)
                        Settings.writeErrorToLog("Error while recieving EarthLink UDP Data." + Environment.NewLine + e.Message);


    But i'm unsure how to do it with TCP/IP. Any help would be awesome!

    killer ninja coding monkeys really exist!
    Wednesday, October 8, 2008 10:46 PM