Send TCP packet in C#

后端 未结 6 1137
栀梦
栀梦 2020-12-17 06:55

I want to send a TCP packet (with a custom header) in C#. The building of such packets is no problem, and I have the data in a byte array. But how can I send this packet ove

6条回答
  •  情歌与酒
    2020-12-17 07:30

    For sending your own crafted TCP packet on Windows 7, you will need a driver like WinPcap. If you use WinPcap, you can use one of the many .NET wrappers or code your own. Sending a raw frame only with objects provided by the Windows API (like sockets) will not work.

    Just look in TCP/IP Raw Sockets.

    The only alternative would be to create your own network monitoring driver, or to buy a commercial version of WinPcap which does not require installation but integrates seamlessly into your program.

    On Windows 7, Windows Vista, Windows XP with Service Pack 2 (SP2), and Windows XP with Service Pack 3 (SP3), the ability to send traffic over raw sockets has been restricted in several ways:

    TCP data cannot be sent over raw sockets.

    For the case you change your mind. Maybe you can find something you need in the library eExNetworkLibrary.

    It includes a WinPcap wrapper and a lot of methods and objects to craft and analyze packets. May it will be useful.

提交回复
热议问题