Hi,
I search to create a dynamique ARRAY of Connection function and start in multi Threard all connection at the same time, send to server requested information. I read a XML file that contain X socket information, i read this XML to put in a Socket Array
Code Example :
Code:
Connection connection[X];
SockAddr server[X];
Thread TestServ[X];
GlobalStruct Globalarray[X];
Reading XML ... to pupolate SockAddr Array
Code:
FREPA(XML_Server_List.nodes)
{
str IP = XMLFav.nodes[i].params(0).value;
Str PORT= XMLFav.nodes[i].params(0).value;
server[i].setIP( IP, CalcR(PORT) );
}
Creation Multi Theard of connection...
Code:
FREPA(server)
{
TestServ[i].create(ServerTest, 0,0,0, ptr(i) );
}
Code:
bool ServerTest(Thread &thread_caller)
{
uint iref = (UIntPtr)thread_caller.user;
if ( connection[iref].clientConnectToServer(server[iref]) )
{
File ServTestSend;
ServTestSend.writeMem();
ServTestSend.putInt(SERVER_INFO);
ServTestSend.pos(0);
connection[iref].dataFull(ServTestSend, ServTestSend.size(), true);
if(connection[iref].receive(3000))
{
connection[[iref].data.pos(0);
byte typeP=connection[[iref].data.getByte();
switch (typeP) {
case SERVER_INFO :
Globalarray[iref].NAME = connection[iref].data.getStr();
Globalarray[iref].STATE = "ON";
Globalarray[iref].VERSION = connection[iref].data.getStr();
Globalarray[iref].NBP = connection[iref].data.getStr();
break;
}
}
}
1 : When i start the Multi Theard of connection, eatch server receive request X time for each Theard ...
2 : Array as always CONSTANT, but i need to change the number of occurence of each array dynamicaly, it is possible to add occurence or delete occurence and rezise Array dynamicaly ? if yes how to ?
3 : Server receive connection but never the packet <SERVER_INFO> request. i have test with one connection, and i need to wait the GREETED State before Send my request... it is possible to bypass that ?
4 : I dont use Update section, because i want each Theard to wait the anwser of each server. i use a receive delay to 3 seconds. But i never reveive anwser in the theard...
Can anyone help me please ?
Avatar