Fix port transmission
This commit is contained in:
parent
ecb49e1117
commit
d6ddbce375
Binary file not shown.
Binary file not shown.
|
@ -156,7 +156,7 @@ int multicastTerminal(struct middleware_arg* arg){
|
|||
/* 3. Si on a le port -> on le met dans la reponse */
|
||||
}else{
|
||||
strcpy(request.addr, SERV_HOST);
|
||||
request.port = htons(comInfo.sin_port);
|
||||
request.port = comInfo.sin_port;
|
||||
if( DEBUGMOD&SCK ) printf("{%s}{udp_com} socket opened on %s:%d\n", arg->entity, request.addr, request.port);
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -34,7 +34,7 @@ public class CommandTerminal {
|
|||
|
||||
try {
|
||||
DatagramSocket socket = new DatagramSocket();
|
||||
ByteBuffer buf = ByteBuffer.allocate(19);
|
||||
ByteBuffer buf = ByteBuffer.allocate(21);
|
||||
buf.clear();
|
||||
buf.put((byte)(0x01|0x02));
|
||||
|
||||
|
@ -47,26 +47,23 @@ public class CommandTerminal {
|
|||
|
||||
if(buf.get() == 3){
|
||||
System.out.println("--Connection request successful");
|
||||
byte address[] = new byte[9];
|
||||
buf = buf.get(address,0,9);
|
||||
byte address[] = new byte[15];
|
||||
buf = buf.get(address,0,15);
|
||||
String addressString = new String(address);
|
||||
InetAddress sgcaAddress = InetAddress.getByName(addressString);
|
||||
buf = buf.get(address,0,7);
|
||||
short shortVal = buf.getShort();
|
||||
int port = shortVal >= 0 ? shortVal : 0x10000 + shortVal;
|
||||
//emulate an unsigned short
|
||||
char cast = buf.getChar();
|
||||
int port = (int) cast;
|
||||
System.out.println("----Address : "+sgcaAddress.getHostAddress());
|
||||
System.out.println("----Port : "+port);
|
||||
}
|
||||
|
||||
|
||||
} catch ( IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue