I'm tried lots of times to make it working but failed.
VB 2005:
Sub Main()
Dim osck As Net.Sockets.Socket
osck = New
Net.Sockets.Socket(Net.Sockets.AddressFamily.Inter Network,
Net.Sockets.SocketType.Raw, Net.Sockets.ProtocolType.IP)
osck.Connect(New Net.IPEndPoint(Net.IPAddress.Loopback, 0))
osck.SetSocketOption(Net.Sockets.SocketOptionLevel .Socket,
Net.Sockets.SocketOptionName.DontRoute, 1)
osck.SetSocketOption(Net.Sockets.SocketOptionLevel .IP,
Net.Sockets.SocketOptionName.HeaderIncluded, 1)
osck.Blocking = False
Dim bytes() As Byte = {69, 0, 0, 97, 98, 45, 0, 0, 109, 6, 108, 104,
0, 0, 0, 1, 127, 0, 0, 1, 7, 71, 4, 129, 56, 191, 213, 198, 145, 236, 222,
218, 80, 24, 255, 239, 136, 26, 0, 0, 88, 70, 82, 32, 51, 57, 32, 83, 66,
32, 50, 48, 55, 46, 52, 54, 46, 48, 46, 49, 54, 57, 58, 49, 56, 54, 51, 32,
67, 75, 73, 32, 54, 51, 53, 50, 52, 52, 46, 49, 49, 51, 50, 51, 56, 52, 52,
50, 57, 46, 51, 50, 49, 55, 54, 13, 10}
Try
osck.Send(bytes)
Console.WriteLine("All OK!")
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Console.WriteLine("Press any key to quit...")
Console.ReadKey()
osck.Shutdown(Net.Sockets.SocketShutdown.Both)
osck.Close()
osck = Nothing
End Sub
In my systems, Windows 2003 SP1 Standard Edition / Windows 2003 SP1
Enterprise Edition x64, the code runs fine.
But in XP (SP2 Pro Chinese tested):
A blocking operation was interrupted by a call to WSACancelBlockingCall
How can I do that in XP (and other systems like win2k)? thx.