Hi guys,
I'm having a little trouble on my code.
What happens is that my Server code works GREAT! But only for one client. Which isn't what I want.
So I was wondering if I could get some help on my current code:
When a server needs to interact with multiple clients at once, you generally have two solutions:
1. Event-driven communication. Each 'tick' of your server you process requests and respond immediately. This is useful for e.g. a game server, where no large data needs to be sent and server/client interaction is generally not time consuming.
2. The dreaded Multithreadng. When a client connects the server starts a thread dedicated to being that client's indentured servant. This is useful for e.g. web/file servers where client communication is lengthy and would delay interaction with other clients.
There are probably other solutions - I'm not exceptionally experienced in networking, I just understand the concepts and have had some experience with high-level networking.
@coder777: I see,
How does this work?
Does _beginthread basically restart the thread?
Would this require me to move my server code from "int main()" to "void ClientThread()"?
Okay, I got it =P
But now, here is what happens--
If they server isn't online, the client cannot connect (like usual).
But if the server IS online, the client can only connect when the server closes (before I added this, it was running fine). It will just sit there and wait for the server to close, and when it does, it runs as if connected.
However, if I have two clients and then close the server, they both connect how I want it to =D but I still have to wait for the server to close in order for both clients to connect.
Still nothing =(
I'll try tweaking around with it, but I'm not having any luck..
What I mean by "Server close" is this:
-I open the server - It connects successfully!
-I open the client app - Nothing happens, the screen is black and says "Not Responding".
-I press the red 'X' on the top-right of the server app (close it).
-Client App starts working as if its connected to the server! But it is closed.
So the client app does not work until I close the server app.
It's really weird...