You are here

TutorialLibraryTest ApplicationDownload
[Tutorial]LibraryTest ApplicationDownload

Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2404 of /home/quantics/public_html/dp/includes/menu.inc).

Socket Tutorial

Chapter 7 - Creation of clients and servers

C_Scokets::NewServer (unsigned int maxLink, unsigned int *pID)

This function creates a server by instantiating a C_SCP object that can accept up to MaxLink client connections. pID is used to return the server ID if successful. This identifier has nothing to do with a socket identifier, which is inaccessible from outside. The code is relatively simple and consists in checking that our array of C_SCP objects is not full, then in adding the new server.

for (i = 0; i < w_maxCS; i ++)
   if (w_pTabSCP [i] == NULL) break;

if (i >= w_maxCS) {

   (...)
		
   er.errorCode=ERROR_MAXCLIENTSERVER_REACHED;
   return er;
}

w_pTabSCP [i] = new C_SCP (maxLink);
w_pTab_C_S [i] = false;

w_pTabSCP [i]->ID = ++w_lastID;
if (pID != NULL) *pID = w_pTabSCP [i]->ID;

C_Scokets::NewClient (unsigned int *pID)

This function creates a client by instantiating a C_SCP object that can establish a connection with a server. pID is used to return the client ID if successful. This identifier has nothing to do with a socket identifier, which is inaccessible from outside. The code is relatively simple and consists in checking that our array of C_SCP objects is not full, then in adding the new client.

for (i = 0; i < w_maxCS; i ++)
   if (w_pTabSCP [i] == NULL) break;

if (i >= w_maxCS) {

   (...)
			
   er.errorCode=ERROR_MAXCLIENTSERVER_REACHED;
   return er;
}

w_pTabSCP [i] = new C_SCP (1);
w_pTab_C_S [i] = true;

w_pTabSCP [i]->ID = ++w_lastID;
if (pID != NULL) *pID = w_pTabSCP [i]->ID;