void AceptoConexiones(SOCKET Socket)
{
SOCKET SockConexion;
SOCKADDR_IN DireccionLocal;
struct IP nuevaIP;
int tamano = sizeof(DireccionLocal),crear,no_cliente=0;
while(1){
no_cliente++;
SockConexion = accept (Socket, (struct sockaddr*)&DireccionLocal,&tamano);
mnsj = mnsj + " nConexion entrante desde:n" + (String)inet_ntoa(DireccionLocal.sin_addr) + (String)(DireccionLocal.sin_port);
nuevaIP.IPDireccion = DireccionLocal;
nuevaIP.IPPuerto = DireccionLocal.sin_port;
nuevaIP.IPSocket = SockConexion;
nuevaIP.cliente = no_cliente;
lect_con = CreateThread(NULL, 0,(LPTHREAD_START_ROUTINE)Hilo_del_cliente,(void *)&nuevaIP,0,&Thread_lect);
}
}
//----------------------------------------------------------------------------
void *Hilo_del_cliente(void *nuevaIP){
struct IP *nueva = (struct IP*)nuevaIP;
SOCKET RemoteSocket = nueva->IPSocket;
unsigned short portclient = nueva->IPPuerto;
SOCKADDR_IN DireccionLocal = nueva->IPDireccion;
String Usuario;
ShowMessage("Entre al hilo que atiende al cada cliente");
char buffer[1000],use[1000],usua[300],cont[300],idio[300],esta[300];
int nBytesSent;
int nBytesRecv;
int opcion,idi,est,existe;
struct nodo *nuev =NULL;
struct nodo *L;
ZeroMemory(buffer,1000);
nBytesRecv = recv (RemoteSocket,(char *)&buffer, sizeof (buffer), 0);
mnsj = mnsj + " nConexion entrante desde:n" + (String)inet_ntoa(DireccionLocal.sin_addr) + (String)portclient;
mnsj = mnsj + "t recibi Opcion: " + buffer;
opcion = atoi(buffer);
//aqui el codigo del logeo ya lo hace y todo esta bien
//me falta poner el del registro
switch(opcion)
{
case 1:
//lo de mensaje de usuario y todo eso solo lo puse para ver si llegaban los datos
recv (RemoteSocket,(char *)&buffer, sizeof (buffer), 0);
mnsj = mnsj + "t recibi Usuario: " + buffer;
strcpy(usua,buffer);
recv (RemoteSocket,(char *)&buffer, sizeof (buffer), 0);
mnsj = mnsj + "t recibi Pasword: " + buffer;
strcpy(cont,buffer);
recv (RemoteSocket,(char *)&buffer, sizeof (buffer), 0);
mnsj = mnsj + "t recibi Nick: " + buffer;
strcpy(idio,buffer);
recv (RemoteSocket,(char *)&buffer, sizeof (buffer), 0);
mnsj = mnsj + "t recibi Idioma: " + buffer;
strcpy(esta,buffer);
existe = validacion(usua,cont,idio,esta);
idi = atoi(idio);
est = atoi(esta);
if (existe == 1)
{
ShowMessage("EXISTE Y LA CONTRASEÑA ES CORRECTA");
nuev = crea_nod(usua,usua,idi,est,portclient,lect_con,DireccionLocal,RemoteSocket);
//aqui es donde le mando la lista a el cliente pero se me bloquea y ninca llega, alguna idea de como mandar la lista de los contactos???
strcpy(buffer,"SI");
recv (RemoteSocket,(char *)&buffer, sizeof (buffer), 0);
}
else
{
ShowMessage("NO EXISTE FAVOR DE VERIFICAR LOS DATOS");
//aqui cuando le envio a el cliente el mensaje de que elcliente no esta logeado correctamente me manda un error o bien me manda numeros NO la cadena de caracteres que quiero
strcpy(buffer,"NO");
recv (RemoteSocket,(char *)&buffer, sizeof (buffer), 0);
}
break;
case 2:
//registro
char nomb[60],appa[60],apma[60],ciud[60],pais[60],usua[60],cont[60],preg[60],resp[60],idio[60],diac[60],mesc[60],anioc[60],sexx[60],queryc[100];
int anac,mnac,dnac;
mnsj = "Estoy en la opcion2";
//aqui va el codigo del registro
break;
default:
ShowMessage("NO HAY NINGUNA OPCION");
}
}