Accept() accepts only one Client !!

Started by
11 comments, last by Rycross 14 years, 5 months ago
i called the 2 functions
i created a function named "Server::Recive" and "Server::Send" then i used it
in the main file after "Server::Start" and if i remove the loop i can exchange informations but only with 1 Client
and when i add it i cannot no more do it
Advertisement
Stop.

Your understanding of C++ is too weak to allow you to proceed to make this program.

Seriously, take a step back and start writing some smaller programs. Learn the basics. If you don't know what a collection is, you won't be able to write this program. If you cannot write a correct loop, you won't be able to write this program.

These are things you have to learn before you can worry about the detail of interacting with the socket API. You don't appear to understand socket handles yet.

If you continue, with our help you might be able to piece together a simple program that kindof works under limited conditions. But:

  • It won't be your work.

  • You won't truely understand it.

  • You won't be able to extend it


Is that what you want?

Again, this is not to put you down. This is about getting you up to speed with C++ so you can properly pursue your goal of writing this program. When you are ready to learn, I will be more than willing to give you actual help.
Quote:Original post by James_Alex
i called the 2 functions
i created a function named "Server::Recive" and "Server::Send" then i used it
in the main file after "Server::Start" and if i remove the loop i can exchange informations but only with 1 Client
and when i add it i cannot no more do it


The fact that you're having trouble with this seems to indicate that you're in way over your head and need to take a step back.

1) Accept gives you a socket to a single client. You must always accept on the listening socket.
2) You must hold on to each socket for each client.
3) You must do send/receive calls on the specific socket for the specific client you want to communicate with.
4) Your program will not magically hold on to sockets, or route send/receives to the correct socket (client) for you. You must manage this yourself.

You need to add your sockets to some sort of container, and use send/receive on the correct socket for the client you wish to communicate with. This is pretty basic stuff, so if you *still* don't understand, you need to start again from the beginning until you do.

This topic is closed to new replies.

Advertisement