lab12
lab12

Reputation: 6448

VB.NET Chat System

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

Upvotes: 0

Views: 1773

Answers (1)

Trevor Tubbs
Trevor Tubbs

Reputation: 2117

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.

Upvotes: 1

Related Questions