• Post Reply Bookmark Topic Watch Topic
  • New Topic

Datagram  RSS feed

 
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: 1048
2
IntelliJ IDE Java Spring
  • 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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!