Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client Server connection

Status
Not open for further replies.

MirauderMo

Programmer
Feb 6, 2002
3
DE
I use the ServerSocket class and the ClientSocet class of c++ builder. the communiction is working fine, but I want the server to don't accept any more client if one client is connected. It is for a two player game.

please help me

thanks
 
if its for a two player game, then why dont you have the first person be the server and the second the client. they can send information back and forth. Cyprus
 
I have the first person as a server and the second as the client. my problem is that if one more client try to connect to the server. this client should not be acceptet by the server. an now I need to know how to say do not accept any more client.
 
I have written FAQ101-1000.
That is a description how to program your own server socket.

In the listen routine there is one parameter NR_OF_CONNECTIONS which defines the number of possible connections before the socket blocks the connection.

I could not find this in the TServerSocket Class.
hnd
hasso55@yahoo.com

 
what you can do is make a global integer, say numclients. Then in the OnClientConnect event, type numclients++

if (numclients >= 0)
{
/* drop the client */
/* I know the code below isn't correct, but I don't remember the function */
try
{
ServerSocket->Socket->Connections[1]->Disconnect;
}
catch(...)
{
/* something went wrong */
}
} Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top