Select() UDP and TCP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • themadme
    New Member
    • Mar 2007
    • 53

    Select() UDP and TCP

    hi. ok my problem is that i have been using TCP for a while and now i want to change to UDP. Im using the select I/0 method.

    i have a listening thread like this :
    Code:
    void Server::vListeningThread( LPVOID pParam )
    {
    	Server *pServer = (Server*)pParam;
    	SOCKET socketClient;
    	do
    	{
    		socketClient = accept( *pServer->p_socketServer, 0, 0 );
    
    		if ( socketClient == SOCKET_ERROR || pServer->usNumberOfClients >= pServer->usMAX_CLIENTS ) 
    		{
    			// send an error code to client //////////////////////////////////////
    			closesocket( socketClient );
    		}
    		else 
    		{
    			WaitForSingleObject( pServer->handleMutex, INFINITE );
    			FD_SET( socketClient, &pServer->fdsetMaster );
    			ReleaseMutex( pServer->handleMutex );
    			pServer->usNumberOfClients++;
    		}
    
    	}while( pServer->bConnected );
    
    }
    now im unsure how to change it into UDP.

    does the new socket of data that has been sent go straight into the FD_SET? Therefore when im polling through the set i would have to check if it has been set or not?

    Please help, im a little bit confused with this?

    thanks
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    This looks like C/C++ code, am I right?

    If so, I will move this over to the C/C++ Forum.

    Comment

    • themadme
      New Member
      • Mar 2007
      • 53

      #3
      well yeah, im using WinSock, thought it would more suitable for the network forums. Ok please move it to the c++ forums

      Comment

      • themadme
        New Member
        • Mar 2007
        • 53

        #4
        actually ill just create a new one on c++ forums. this can be deleted

        Comment

        Working...