Concurrent Connections

S

Steven Blair

Hi,

I have Server application which handles a single conenction froma client.
I want this program to accept concurrent connections.

Anyone help me out ?

I am using a TcpListener object. I thought that this would accept concurrent
connections, but apparently not, sicne I have my server running and connect
using 2 sessions of telnet and only seems to register one connection.

Any help on this is appreciated
 
J

Jonathan

Whenever your server accept a connection, a new thread should be spawned
off and further interaction with that connection should take place in
that thread. Then your server main thread go back to listening mode.
 
S

Steven Blair

Hi,

When the server accepts a connection, does a new thread automatically get
spawned or is the programmer responsible for this ?

Here is my code:

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

listener.Bind(new IPEndPoint(IPAddress.Any,5005));

listener.Listen(0);

listBox1.Items.Add("Listening...");

listener.Accept();

Thread thread = new Thread(new ThreadStart(ClientConnected));

thread.Start();

So I start a new thread after Accept method.

Any more help on this would be appreciated. The strange thign is, i can
connect 2 telnet sessions to the server, altho only recieve text from the
first instance.

Steven
www.stevenblair.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top