-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolicitud.cpp
More file actions
50 lines (47 loc) · 1.23 KB
/
Copy pathSolicitud.cpp
File metadata and controls
50 lines (47 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "Solicitud.h"
#include "SocketDatagram.h"
#include "PaqueteDatagrama.h"
#include "mensaje.h"
#include <iostream>
#include <cstring>
using namespace std;
#define TAM_MAX_DATA 4000
Solicitud::Solicitud()
{
socketlocal= new SocketDatagrama(0);
}
char * Solicitud::doOperation(char *IP, int puerto, int operationId, char *arguments)
{
//printf("hola\n");
struct mensaje m;
memcpy(m.arguments,arguments,TAM_MAX_DATA);
m.messageType=0;
m.requestId=operationId;
PaqueteDatagrama b((char *)&m,sizeof(struct mensaje),IP, puerto);
//printf("hola\n");
int cont=0;
int n = -1;
PaqueteDatagrama c(sizeof(struct mensaje));
do
{
n = socketlocal->envia(b);
//printf("Enviados: %d\n",n);
//printf("arme\n");
//PaqueteDatagrama c(sizeof(struct mensaje));
n = socketlocal->recibeTimeout(c,2,500000);
//printf("recibi\n");
cont++;
}while(cont<7 && n==-1);
if(cont==7){
exit(0);
}
char aux[4000];
int aux2;
//memcpy(&aux2,c.obtieneDatos(),sizeof(int));
struct mensaje m2;
memcpy(&m2,c.obtieneDatos(),sizeof(struct mensaje));
struct mensaje* aux3;
aux3 = &m2;
//printf("%d\n",aux2);
return(char *) aux3;
}