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
You should use SocketType.Stream:
SocketType.Raw: Supports access to the underlying transport protocol. Using the SocketTypeRaw, you can communicate using protocols like Internet Control Message Protocol (Icmp) and Internet Group Management Protocol (Igmp). Your application must provide a complete IP header when sending. Received datagrams return with the IP header and options intact.
SocketType.Stream: Supports reliable, two-way, connection-based byte streams without the duplication of data and without preservation of boundaries. A Socket of this type communicates with a single peer and requires a remote host connection before communication can begin. Stream uses the Transmission Control Protocol (Tcp) ProtocolType and the InterNetworkAddressFamily.