Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C Windows programming udp , +
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 19-Apr-13 20:07pm
Edited 19-Apr-13 21:14pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 20 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100