This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Datagram Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Datagram" Watch "Datagram" New topic


Bill Ceglia
Ranch Hand

Joined: Dec 13, 2001
Posts: 30
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;
dc = (DatagramConnection);
// Create a datagram socket and send
Datagram dgram = dc.newDatagram(message,message.length,destAddr);
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

Here and here are a couple of referances from "TCP/IP Sockets in Java" by Calvert & Donahoo.

Please ignore post, I have no idea what I am talking about.
I agree. Here's the link:
subject: Datagram
It's not a secret anymore!