Hi everybody,

I want to send a UDP Broacast with C# but i want to change the source
adress and the source port of the packet.

I know that since XP sp2 these things have been limited but as far as
i know this just concerns networks which aren't connected to the host
in any way. For example the host is in the 192.168.1.0 net can't send
a packet with the source adress 143.xxx.xxx.xxx but he can send a
packet with an 192.168.1.0 source adress even if its not his own.
I think that at least :). Hope thats the case...

Anyway, i read already that this is possible with RAW-Sockets but i
dont know how...
Till now i just have the code for sending the broadcast:

 private void SendBroadcast(Paket paket)
        {
            Socket broadcastSocket = new Socket
(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Udp);

            IPEndPoint endpoint = new IPEndPoint(IPAddress.Broadcast,
Convert.ToInt32(paket.Udpheader.DestinationPort));

            broadcastSocket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.Broadcast, 0);
            broadcastSocket.SendTo(paket.Udpheader.Data, endpoint);
            broadcastSocket.Close();
        }


But i don't know how i can set the source Adress or source port...
I hope somebody can give me a tipp :)

Thanks for the help in advance,
Metabolic

Reply via email to