Mocking TCP / IP connection with C #

I’m a bit n00b network, so please be gentle and explain things in a REALLY fictitious way (it seems to me that every time when it comes to network-related things, people start to speak a completely different language), I'm a pretty experienced programmer in C #, but I lack communication skills between machines.

The scenario is this: I am working with a product that interacts with other devices through tcp / ip. Is it possible to create a dummy program that acts like a ta tcp / ip connection (locally on my machine), so I can connect my other program to it by setting my IP address (and port), and then return everything that mocks / test data I want?

+5
source share
4 answers

Honestly, I don’t see the point of β€œtaunting” anything here, I just use the proper TCP / IP connection, because obviously you can send data via TCP / IP between two different applications at the same IP address.

Check out this example:

http://www.codeproject.com/KB/IP/tcpclientserver.aspx

0
source

Yes: you can configure the TCP connection to a program running on your own machine. The host name you should use is this localhost, or the IP address 127.0.0.1: see Also Loopback (Virtual Network Interface) .

0
source

. Mocking , :

http://www.codeproject.com/KB/biztalk/Excellence.aspx

This allows you to configure data to send and receive. You may need to adjust it a bit, but the main material already exists.

I think that interests you TcpReceiveMiniServer.

Here is a mini sample:

    static void Main(string[] args)
    {
        TcpReceiveMiniServer server = new TcpReceiveMiniServer(8789);
        server.Start();
        server.DataArrived += new TcpReceiveMiniServer.DataArrivedHandler(server_DataArrived);
        Console.Read();
    }

    static void server_DataArrived(object sender, DataArrivedEventArgs e)
    {
        // do something with e.Data
    }
0
source

All Articles