Re: blocking non blocking



I see. I coded mine to use asynchronous calls, (tcp stream), stays connected
for the duration of the client app.

I have thought that in an async set up that on connecting it spawns a thread
for that client?

Here is some of my server code, as you can see on every connect i fire off
the asyncallback method to handle the client connection. Which is where i
presumed a thread is spawned and handles that connection? Have i missed out
on some fundamental understanding and inadvertently coded this correctly
anyway?

public void Listen(int PortNo)

{

_portNo = PortNo;

try

{

//create the listening socket...

_socListener = new
Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);

IPEndPoint ipLocal = new IPEndPoint ( IPAddress.Any ,_portNo);

//bind to local IP Address...

_socListener.Bind( ipLocal );

//start listening...

_socListener.Listen (4);

// create the call back for any client connections...

_socListener.BeginAccept(new AsyncCallback ( OnClientConnect ),null);


}

catch(SocketException se)

{

MessageBox.Show ( se.Message );

}



}


protected void OnClientConnect(IAsyncResult asyn)

{

try

{

_socWorker = _socListener.EndAccept (asyn);

ClientConnected();


WaitForData(_socWorker);

// create the call back for any client connections...

_socListener.BeginAccept(new AsyncCallback(OnClientConnect), null); //to
allow next client to be able to connect

}

catch(ObjectDisposedException)

{

Console.WriteLine("OnClientConnect: Connection closed
{0}",_socWorker.RemoteEndPoint.ToString());

}

catch(SocketException se)

{

MessageBox.Show ( se.Message, "OnClientConnect::NetServer" );

}

catch(Exception exc)

{

MessageBox.Show("NetServer::OnClientConnect-" + exc.Message,"Failed to
connect - " + exc.GetType());

}


}



protected virtual void WaitForData(System.Net.Sockets.Socket soc)

{

try

{

// if (soc.Connected)

// {

dvSocketPacket theSocPkt = new dvSocketPacket(_bufferSize);

theSocPkt.thisSocket = soc;

theSocPkt.remoteIP = soc.RemoteEndPoint;

// now start to listen for any data...

soc.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length,

SocketFlags.None, new AsyncCallback(OnDataReceived), theSocPkt);

// }

// else

// {

// disconnectEvent(soc.RemoteEndPoint);

//}

}

catch (SocketException se)

{

MessageBox.Show(se.Message, "Error while waiting for data");

}

}




.



Relevant Pages

  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #3]
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... kernel socket family. ... presentation side is left to the client. ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... Make it possible for the client socket to be used to go to more than one ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... Make it possible for the client socket to be used to go to more than one ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • Re: blocking non blocking
    ... connected for the duration of the client app. ... off the asyncallback method to handle the client connection. ... public void Listen(int PortNo) ...
    (microsoft.public.win32.programmer.networks)
  • Re: Remote Client Configuration
    ... the client computer to the SBS domain via connect computer wizard remotely. ... local network or via dial up VPN connection, you will use an local copy on ... connection is established, Group Policy is not applied during logon. ...
    (microsoft.public.windows.server.sbs)