views:

360

answers:

3

Hey guys,

I made a simple chat system that connects to a server with a client one on one. I'm not really sure how to get multiple clients with the server so that you can see everyone's messages. Here is the source code. The Server only accepts one client at a time. how can I fix this?

Thanks,

Kevin

A: 

Take a look at these resources, maybe you can grab some useful ideas:

Creating a simple chat application in .NET
Create a Chat System using Ajax and ASP.NET

Konamiman
I'm using Visual Basic not C#
Kevin
VB.NET and C# both use the .NET framework class library to actually do things. So I posted these links with the hope that by examining them, you would be able to know which classes you need to use and in which way.
Konamiman
A: 

I didn't really go through your codes, but here are a copuple of useful reads:

.NET Sockets in Two Directions with Multiple Client Support (C# Source Code Included)
VB.NET Socket - Multiple clients to server

o.k.w
+1  A: 

In keeping with what you have done so far, here are a few tips to get you started. First, when the client receives a connection it stops listening for new connections.

TCPL.Start()
TCPL.BeginAcceptTcpClient(AddressOf OnConnect, Nothing)

Calling these two lines after one client connects will allow another client to connect. Second, the client should not be responsible for starting the server. By doing this each client has it's own server. The clients will never be able to send a message that is displayed on other clients when they each have their own server. Third, I would move server.vb into it's own project. That way the two are not coupled. These steps will allow the server to accept multiple clients. At this point multiple clients will be able to connect and the server will see the messages from each client, but the clients will not be able to see each other's messages. I will leave the last hurdle to you.

Guster_Q