Asynchronous Sockets

From: Andrew Ducker (Andrew_at_Ducker.org.uk)
Date: 10/23/04


Date: Sat, 23 Oct 2004 09:30:21 -0700

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



Relevant Pages

  • Re: More people whose website should be better.
    ... "Tim Berners-Lee confirmed as plenary speaker" ... Invalid. ... They haven't heard the conference speakers telling them why it ought to ... Andy Mabbett ...
    (uk.net.web.authoring)
  • Significance of log entries
    ... Subject: Significance of log entries ... peer died: Invalid argument ... Answer will determine if IP should be stuffed in my *.deny files. ... Andy ...
    (Focus-SUN)
  • Re: Asynchronous Sockets
    ... Andrew Ducker wrote: ... > Can anyone tell me the stupid mistake I'm obviously making? ... you don't call listener.Listenbefore BeginAccept ... you spin with the while-loop. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Asynchronous Sockets
    ... >> Can anyone tell me the stupid mistake I'm obviously making? ... >> public void ConnectionMade(IAsyncResult ar) ... you don't call listener.Listenbefore BeginAccept ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Redundency of IsNull(Trim(myvar)) ?
    ... "Andy" wrote in message ... > will give you an error - Invalid use of Null or something ... > because you can not Trim NULL. ... My guess is that the original code should have been ...
    (microsoft.public.vb.general.discussion)