By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,180 Members | 1,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,180 IT Pros & Developers. It's quick & easy.

Concurrent Connections

P: n/a
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

--
Steven
www.stevenblair.com
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
Steven Blair wrote:
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


Nov 15 '05 #2

P: n/a
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,Prot ocolType.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
"Jonathan" <da***********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.
Steven Blair wrote:
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

Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.