Socket = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Raw, System.Net.Sockets.ProtocolType.IP);
try
{
Socket.Bind(new System.Net.IPEndPoint(System.Net.IPAddress.Parse(SelectIP.Text), 0));
//Socket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.IP, System.Net.Sockets.SocketOptionName.HeaderIncluded, true);
byte[] optionInValue = { 1, 0, 0, 0 };
Socket.IOControl(IOControlCode.ReceiveAll, optionInValue, null);
while (btnStop.Enabled)
{
System.IAsyncResult ar = Socket.BeginReceive(PacketBuffer, 0, PacketBufferSize, System.Net.Sockets.SocketFlags.None, new System.AsyncCallback(CallReceive), this);
while (Socket.Available == 0)
{
System.Threading.Thread.Sleep(1);
if (!btnStop.Enabled) break;
}
if (!btnStop.Enabled) break;
int Size = Socket.EndReceive(ar);
if (!LooseQueue.Checked) ExtractBuffer();
}
}
finally
{
if (Socket != null)
{
Socket.Shutdown(System.Net.Sockets.SocketShutdown.Both);
Socket.Close();
}
}
This code works fine on my XP machine, but when I run it on another XP machine it gives error "An invalid argument was supplied." on Socket.IOControl method. All machines have wireless connection. Also I already test by commenting and uncommenting Socket.SetSocketOption line.
I spend lot of time for any web help(including this forum) regarding this type of error but failed to find any solution.
Can anyone solve this problem?