Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Datagram

 
Bill Ceglia
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is the code I use to create and send a datagram. Everything seems to work but I never see the data arrive at the address I specified and most importantly when I debug the code using Code Warrior, the variable dgram is null after I supposedly have populated it? Does this code look correct?
byte[] message = gpsstring.getBytes();
DatagramConnection dc = null;
String destAddr = "datagram://" + hostname + ":" + sendport;
try
{
dc = (DatagramConnection)Connector.open(destAddr);
// Create a datagram socket and send
Datagram dgram = dc.newDatagram(message,message.length,destAddr);
dc.send(dgram);
dc.close();
}
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here and here are a couple of referances from "TCP/IP Sockets in Java" by Calvert & Donahoo.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic