473,396 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Asynchronous Sockets

I have the following code, which throws an error of "An invalid argument
was supplied" when I run it.

Can anyone tell me the stupid mistake I'm obviously making?

Socket listener = new Socket(*snipped*);
listener.Bind(localEndPoint);
while (true)
{
AsyncCallback MyCallback = new AsyncCallback(ConnectionMade);
listener.BeginAccept(MyCallback,listener);
}

public void ConnectionMade( IAsyncResult ar)
{
MessageBox.Show("Got an attempt to connect!");
}

The error happens on the line BeginAccept.

Any suggestions?

Andy D
Nov 16 '05 #1
3 1407
Hi Andrew,

Thank you for posting here. Regarding on the issue, we're
finding proper resource to assist you and we will update as soon as posible.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security(This posting is provided "AS IS",
with no warranties, and confers no rights.)

Nov 16 '05 #2
Andrew Ducker wrote:
I have the following code, which throws an error of "An invalid argument
was supplied" when I run it.

Can anyone tell me the stupid mistake I'm obviously making?

Socket listener = new Socket(*snipped*);
listener.Bind(localEndPoint);
while (true)
{
AsyncCallback MyCallback = new AsyncCallback(ConnectionMade);
listener.BeginAccept(MyCallback,listener);
}

public void ConnectionMade( IAsyncResult ar)
{
MessageBox.Show("Got an attempt to connect!");
}

The error happens on the line BeginAccept.


1. you don't call listener.Listen() before BeginAccept
2. you spin with the while(true){}-loop. BeginAccept is
asynchronous, so it doesn't block.

bye
Rob
Nov 16 '05 #3
Robert Jordan <ro*****@gmx.net> wrote in
news:cl************@news.t-online.com:
Andrew Ducker wrote:
I have the following code, which throws an error of "An invalid
argument was supplied" when I run it.

Can anyone tell me the stupid mistake I'm obviously making?

Socket listener = new Socket(*snipped*);
listener.Bind(localEndPoint);
while (true)
{
AsyncCallback MyCallback = new
AsyncCallback(ConnectionMade);
listener.BeginAccept(MyCallback,listener);
}

public void ConnectionMade( IAsyncResult ar)
{
MessageBox.Show("Got an attempt to connect!");
}

The error happens on the line BeginAccept.


1. you don't call listener.Listen() before BeginAccept


Aaaah! Thank you! That did it.

I feel particularly stupid.

Andy D
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Corne Oosthuizen | last post by:
I'm writing a Telnet Server application using Asynchronous sockets. I spawn a listener thread to handel incomming connections and create a separate client socket for each new connection. I...
9
by: Michael Lindsey | last post by:
I need to write a server app to send images to client GUIs that are outside of the server's domain. The client will have the file system path to the image but can not access the file system. I am...
3
by: Corne Oosthuizen | last post by:
I'm writing a Telnet Server application using Asynchronous sockets. I spawn a listener thread to handel incomming connections and create a separate client socket for each new connection. I...
4
by: taskswap | last post by:
I have a legacy application written in C that I'm trying to convert to C#. It processes a very large amount of data from many clients (actually, upstream servers - this is a mux) simultaneously. ...
2
by: Nicolas Le Gland | last post by:
Hello everyone here. This is my first post in this newsgroup, I hope I won't be to much off-topic. Feel free to redirect me to any better group. I am getting strange timing issues when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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,...

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.