G
Guest
I must say I'm new to these Raw sockets in C# and unfortunantly I haven't met
anyone who is a expert in them which makes trying to develop any rather
difficult.
What I've been doing is trying to create some sort of NAT Server to work as
a ADSL gateway and share internet access. Yes I know I can use ICS, No I'm
not going to. I want to learn shomething by doing this not just use a
standard out of the box solution.
Anyway, I set up my packet reciever which recieves RAW IP packets and dumps
them all onto my processing functions which change around the Source Address
and send the pack off for it's trip onto the internet. However my RAW IP
sender is not happy and I *think* it has something to do with sockets and
blocking and the idea that sends should not overlap or somthing. Anyway the
code goes something like:
sender = new Socket(AddressFamily.InterNetwork, SocketType.Raw,
ProtocolType.IP);
sender.Blocking = true;
sender.Bind(new IPEndPoint(IPAddress.Parse(IP), port));
sender.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.HeaderIncluded, 1);
// Code to make the packet as a byte buffer and finally:
sender.SendTo(send_buf_bytes, args.totallength,
System.Net.Sockets.SocketFlags.DontRoute, new IPEndPoint(args.destination,
0));
At which point the system dies and gives me a cryptic error message saying:
An unhandled exception of type 'System.Net.Sockets.SocketException' occurred
in system.dll
Additional information: A blocking operation was interrupted by a call to
WSACancelBlockingCall
Can anyone see what I missed. I think I maybe need to turn the socket into
non-blocking by use of sender.IOControl but I have no idea what the actuall
call is or what the correct iocontrolcode would be.
Anyone got any ideas? Or does someone know that I am on the compleatly wrong
track and can suggest what I should in fact be doing?
Thanks in advance,
Kevin-John Beasley
anyone who is a expert in them which makes trying to develop any rather
difficult.
What I've been doing is trying to create some sort of NAT Server to work as
a ADSL gateway and share internet access. Yes I know I can use ICS, No I'm
not going to. I want to learn shomething by doing this not just use a
standard out of the box solution.
Anyway, I set up my packet reciever which recieves RAW IP packets and dumps
them all onto my processing functions which change around the Source Address
and send the pack off for it's trip onto the internet. However my RAW IP
sender is not happy and I *think* it has something to do with sockets and
blocking and the idea that sends should not overlap or somthing. Anyway the
code goes something like:
sender = new Socket(AddressFamily.InterNetwork, SocketType.Raw,
ProtocolType.IP);
sender.Blocking = true;
sender.Bind(new IPEndPoint(IPAddress.Parse(IP), port));
sender.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.HeaderIncluded, 1);
// Code to make the packet as a byte buffer and finally:
sender.SendTo(send_buf_bytes, args.totallength,
System.Net.Sockets.SocketFlags.DontRoute, new IPEndPoint(args.destination,
0));
At which point the system dies and gives me a cryptic error message saying:
An unhandled exception of type 'System.Net.Sockets.SocketException' occurred
in system.dll
Additional information: A blocking operation was interrupted by a call to
WSACancelBlockingCall
Can anyone see what I missed. I think I maybe need to turn the socket into
non-blocking by use of sender.IOControl but I have no idea what the actuall
call is or what the correct iocontrolcode would be.
Anyone got any ideas? Or does someone know that I am on the compleatly wrong
track and can suggest what I should in fact be doing?
Thanks in advance,
Kevin-John Beasley