Results 1 to 2 of 2
  1. #1
    php.freak is offline Member
    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Default Problem with Datagram-Sockets

    Hi,

    i have the following problem:

    PHP Code:
    if(!s.isEmpty()) {
              byte[] raw = s.getBytes();
              DatagramPacket packet = new DatagramPacket(raw, raw.length, host, (Integer.getInteger(ServerPort)+1));
              DatagramSocket socket = new DatagramSocket();
              socket.send(packet);
          }
    returns a java.lang.NullPointerException in line 3.

    And this code

    PHP Code:
    DatagramSocket host = new DatagramSocket(Integer.getInteger(ServerPort)+1);
    causes another NullPointerException.

    "ServerPort" is a string, which I already used for a streaming-socket in the same code and it worked.

    Where is my mistake?

    Thanks in advance for your responses and sorry for my bad English ;)

  2. #2
    php.freak is offline Member
    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Default Re: Problem with Datagram-Sockets

    Here is the solution:

    Integer.getInteger() got to be Integer.parseInt()

    Than it works!

Similar Threads

  1. Problem with Sockets
    By shanoger in forum Networking
    Replies: 1
    Last Post: 04-06-2011, 02:21 PM
  2. Problem with Sockets
    By pinheiroa in forum Networking
    Replies: 15
    Last Post: 09-05-2010, 10:53 PM
  3. TCP sockets problem
    By duffman.sk in forum Networking
    Replies: 1
    Last Post: 10-30-2009, 05:06 AM
  4. Problem (sockets)
    By Blacknight962 in forum New To Java
    Replies: 3
    Last Post: 08-16-2009, 12:56 AM
  5. Sockets and JFrames problem
    By marcg11 in forum Advanced Java
    Replies: 6
    Last Post: 08-15-2009, 01:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •