• 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: 1027
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.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!