Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DatagramSocket.receive() error

Status
Not open for further replies.

iamgoodatthis

Programmer
Joined
Nov 12, 2004
Messages
1
Location
US
Hello. I'm getting an unexpected NullPointerException when using the receive method from DatagramSocket. Here is my code:

DatagramPacket waiting = null;
try
{
DatagramSocket socketReceive = new DatagramSocket(100);
socketReceive.receive(waiting);
}
catch(IOException e)
{
}

The exact error is NullPointerException in DatagramSocket, receive method line 647. All help would be appreciated.

Thanks.
 
A NullPointerExpression means that you are referencing a null object. If this is all the code you have, waiting is null and cannot be sent as a DatagramPacket.

P.S.
I have no idea what DatagramSockets or DatagramPackets are, anyway.

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top