×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Client Server connection

Client Server connection

Client Server connection

(OP)
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

RE: Client Server connection

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

RE: Client Server connection

(OP)
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.

RE: Client Server connection

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
 
 

RE: Client Server connection

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close