This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Datagram" Watch "Datagram" New topic
Author

Datagram

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;
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

Joined: Mar 16, 2001
Posts: 984

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: http://aspose.com/file-tools
 
subject: Datagram
 
Similar Threads
Sending Multipart Text Messages using android.telephony.gsm.SmsManager
Sending Email Exception: Illegal whitespace in address
TCP/UDP connection in MIDP
Datagram connection
I don't know what to do!