Click here to Skip to main content
15,867,305 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I have a single asynchronous socket at my server side. whenever there is something to be read or written on the socket, a window's message is generated. Right now there is only one single asynchronous socket on the server that handles requests of more than one client I guess. But I am not sure will this work if number of clients exceed. If I need to handle 40 clients, do I need to create 40 asynchronous sockets at server side to handle request of each of the 40 clients simultaneoulsy? I am not sure how to extend this single server single client application to multiple clients application. Can anybody give me some guidlines how to move forward? below is the code I done at server side with a single asynchronous socket:
WSAAsyncSelect (socketIdentifier, hwnd, MY_MESSAGE_NOTIFICATION, FD_READ | FD_CONNECT | FD_CLOSE | FD_ACCEPT); //Making the socket Asynchronous
   while(GetMessage(&Msg, NULL, 0, 0) > 0) //Waiting for windows messages
      {         
         TranslateMessage(&Msg);
         DispatchMessage(&Msg);
      }
   return Msg.wParam;


    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
       switch(msg)
          {
           case MY_MESSAGE_NOTIFICATION: //Window message generated by asynchronous socket.
            {
             switch (lParam) //If so, which one is it?
                {
                case FD_ACCEPT:
                    //Connection request was made
                    break;

                case FD_CONNECT:
                    //Connection was made successfully
                    break;

                case FD_READ:
                   receiveAtSocket();
                break;

                case FD_CLOSE:
                    //Lost the connection
                 break;
                }
            }
            break;
        }
    }
Posted
Updated 19-Apr-13 20:14pm
v2

1 solution

This question has already been answered in your previous query at Binding 40 Sockets to 40 different IP addresses[^]. If you have further information then please respond to the person who gave you the answer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900