473,499 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Socket Exception: An invalid argument was supplied Error Code 10022

1 New Member
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?

Expand|Select|Wrap|Line Numbers
  1. Socket = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Raw, System.Net.Sockets.ProtocolType.IP);
  2. try
  3. {
  4.  
  5.     Socket.Bind(new System.Net.IPEndPoint(System.Net.IPAddress.Parse(SelectIP.Text), 0));
  6.     Socket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.IP, System.Net.Sockets.SocketOptionName.HeaderIncluded, true);
  7.     byte[] optionInValue = { 1, 0, 0, 0 };
  8.     Socket.IOControl(IOControlCode.ReceiveAll, optionInValue, new byte[] { 1, 0, 0, 0 });
  9.     while (btnStop.Enabled)
  10.     {
  11.         System.IAsyncResult ar = Socket.BeginReceive(PacketBuffer, 0, PacketBufferSize, System.Net.Sockets.SocketFlags.None, new System.AsyncCallback(CallReceive), this);
  12.         while (Socket.Available == 0)
  13.         {
  14.             System.Threading.Thread.Sleep(1);
  15.             if (!btnStop.Enabled) break;
  16.         }
  17.         if (!btnStop.Enabled) break;
  18.         int Size = Socket.EndReceive(ar);
  19.         if (!LooseQueue.Checked) ExtractBuffer();
  20.     }
  21.  
  22. }
  23.  
May 21 '10 #1
0 2519

Sign in to post your reply or Sign up for a free account.

Similar topics

6
10128
by: Clarence Gardner | last post by:
I've got a problem that I don't see how to program around. A socket server that was running fine, today started getting an exception from the bind() call (errno 22, Invalid argument) and yet the...
5
5432
by: Nuno Magalhaes | last post by:
I'm trying to set a multicast server but I get "Invalid argument" when setting multicast options. Below is the code that gives me problems more precisely in SetSocketOption with the AddMembership...
3
9201
by: ralphdepping | last post by:
Trying to get moinmoin wiki working on Windows 2000 using IIS and python. I get the following error when trying to view the start page after insalling moinmoin and python - key error seems to be...
2
2686
by: Steve Walton | last post by:
We have a little server application that sends data down to a client application via a TCP/IP socket over port 30006. These applications are both written in C#. They have been working on our site...
3
6176
by: Don M | last post by:
The code below works fine in IE7 and Firefox2 but gets an "Invalid Argument" error in IE7. I've tried quotes around "ShowContent" ( I've used double " and single ' ) but it doesn't work at all with...
1
1328
by: guoxin | last post by:
Hi All, May i know how to rectify the following php error? Thanks folks Warning: Invalid argument supplied for foreach() in /home/alan/do_add-user.php on line 36 do_add-user.php.php on...
1
1616
by: BryanA | last post by:
Something seems to be wrong with this function and I can't figure out why it is failing. The error that it gives is; Invalid argument supplied for foreach() . function transposition($words){...
14
3325
by: rashgang | last post by:
i have dynamically created checkbox which will like yahoo mail if check box selected it will highlight a row but deleteall function is not working plz chek it function doDeleteAll($objArray){ ...
4
6277
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59...
1
2260
by: mahhood | last post by:
Here is the complete code. <?php // ****: holder.php - v. 5.03 // PRELIMINARIES: // Get Includes:
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7392
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.