now I have this code
Code:
while(AcceptSocket==SOCKET_ERROR)
{
Acceptsocket=accept(socketInTCP,NULL;NULL)
}
socketInTCP=AcceptSocket
while(run_tcpserver)
{ //comprobar length_dummy, abrir fichero, blucle, cerra fichero
bytesRecv = recv(socketInTCP, recvbuf, sizeof(recvbuf), 0);
if (bytesRecv > 0)
{if(ctr1==1)
{
p=ntohs(clientService.sin_port);
cout << "port the first time it receives:" << p << "\n";
m=0;
}
ctr1=0;
port_array[m]=ntohs(clientService.sin_port);
m++;
ofstream outfile(outputfile, ios::out |ios::ate | ios::binary);//open
rcv_data=rcv_data+bytesRecv;
cout << "\xd" << rcv_data;
outfile.write (var, sizeof(var));
outfile.close();
memset(recvbuf,0,sizeof(recvbuf));
if(rcv_data==(length_dummy*4))
{
ReleaseMutex(req_mutex);
}
}
}
the first time p=2000
and
the second time
port_array[0]=2000
but
port_array[1]=49154.....