@@ -243,7 +243,7 @@ public String getServerHost() {
243
243
*/
244
244
public int getServerPort () {
245
245
if (currentParsedUDL == null ) return 0 ;
246
- return currentParsedUDL . nameServerTcpPort ;
246
+ return domainServerPort ;
247
247
}
248
248
249
249
@@ -484,17 +484,26 @@ public void run() {
484
484
packet .setLength (1024 );
485
485
try {
486
486
udpSocket .receive (packet );
487
+ if (debug >= cMsgConstants .debugInfo ) {
488
+ System .out .println ("UdpReceiver.run(): Received a multicast response" );
489
+ }
487
490
}
488
491
catch (SocketTimeoutException e ) {
489
492
// Check to see if we've been asked to quit
490
493
if (Thread .interrupted ()) {
494
+ if (debug >= cMsgConstants .debugInfo ) {
495
+ System .out .println ("UdpReceiver.run(): Thread interrupted" );
496
+ }
491
497
return ;
492
498
}
493
499
continue ;
494
500
}
495
501
496
- // if packet is smaller than 6 ints ...
497
- if (packet .getLength () < 24 ) {
502
+ // if packet is smaller than 5 ints ...
503
+ if (packet .getLength () < 20 ) {
504
+ if (debug >= cMsgConstants .debugInfo ) {
505
+ System .out .println ("UdpReceiver.run(): Packet size smaller that 5 ints" );
506
+ }
498
507
continue ;
499
508
}
500
509
@@ -507,48 +516,60 @@ public void run() {
507
516
if ( (magicInt1 != cMsgNetworkConstants .magicNumbers [0 ]) ||
508
517
(magicInt2 != cMsgNetworkConstants .magicNumbers [1 ]) ||
509
518
(magicInt3 != cMsgNetworkConstants .magicNumbers [2 ])) {
510
- //System.out.println(" Bad magic numbers for multicast response packet");
519
+ if (debug >= cMsgConstants .debugInfo ) {
520
+ System .out .println ("UdpReceiver.run(): Bad magic numbers for multicast response packet" );
521
+ }
511
522
continue ;
512
523
}
513
524
514
- currentParsedUDL .nameServerTcpPort = cMsgUtilities .bytesToInt (buf , 12 ); // port to do a direct connection to
515
- if ((currentParsedUDL .nameServerTcpPort < 1024 || currentParsedUDL .nameServerTcpPort > 65535 )) {
516
- //System.out.println(" Wrong format for multicast response packet");
525
+ domainServerPort = cMsgUtilities .bytesToInt (buf , 12 ); // xMsg Proxy server port
526
+ if ((domainServerPort < 1024 || domainServerPort > 65535 )) {
527
+ if (debug >= cMsgConstants .debugInfo ) {
528
+ System .out .println ("UdpReceiver.run(): Bad port in multicast response packet" );
529
+ }
517
530
continue ;
518
531
}
519
532
520
- // udpPort is next but we'll skip over it since we don't use it
521
-
522
533
// # of address pairs to follow
523
- int listLen = cMsgUtilities .bytesToInt (buf , 20 );
534
+ int listLen = cMsgUtilities .bytesToInt (buf , 16 );
524
535
if (listLen < 0 || listLen > 50 ) {
525
- System .out .println (" Wrong format for multicast response packet, listLen = " + listLen );
536
+ if (debug >= cMsgConstants .debugInfo ) {
537
+ System .out .println ("UdpReceiver.run(): Wrong format for multicast response packet, listLen = " + listLen );
538
+ }
526
539
continue ;
527
540
}
528
541
529
- int pos = 24 ;
542
+ int pos = 20 ;
530
543
String ss ;
531
544
int stringLen ;
532
545
ipList .clear ();
533
546
broadList .clear ();
547
+
548
+ if (debug >= cMsgConstants .debugInfo ) {
549
+ System .out .println ("UdpReceiver.run(): listLen = " + listLen );
550
+ }
534
551
535
552
for (int i =0 ; i < listLen ; i ++) {
536
553
try {
537
554
stringLen = cMsgUtilities .bytesToInt (buf , pos ); pos += 4 ;
538
- //System.out.println(" ip len = " + listLen);
539
555
ss = new String (buf , pos , stringLen , "US-ASCII" );
540
- //System.out.println(" ip = " + ss);
556
+ if (debug >= cMsgConstants .debugInfo ) {
557
+ System .out .println (" ip = " + ss );
558
+ }
541
559
ipList .add (ss );
542
560
pos += stringLen ;
543
561
544
562
stringLen = cMsgUtilities .bytesToInt (buf , pos ); pos += 4 ;
545
- //System.out.println(" broad len = " + listLen);
546
563
ss = new String (buf , pos , stringLen , "US-ASCII" );
547
- //System.out.println(" broad = " + ss);
564
+ if (debug >= cMsgConstants .debugInfo ) {
565
+ System .out .println (" broad = " + ss );
566
+ }
548
567
broadList .add (ss );
549
568
pos += stringLen ;
550
569
}
551
- catch (UnsupportedEncodingException e ) {/*never happen */ }
570
+ catch (UnsupportedEncodingException e ) {
571
+ System .out .println ("UdpReceiver.run(): encoding error" );
572
+ }
552
573
}
553
574
break ;
554
575
}
0 commit comments