Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4098556
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:19:03+00:00 2026-05-20T20:19:03+00:00

Everytime I try to send a UDP packet to an address I get the

  • 0

Everytime I try to send a UDP packet to an address I get the following exception:

java.lang.ArrayIndexOutOfBoundsException
    at java.net.PlainDatagramSocketImpl.send(Native Method)
    at java.net.DatagramSocket.send(DatagramSocket.java:625)
    at services.servicetypes.network.host.Server_UDP_Thread_Monitor.send(Server_UDP_Thread_Monitor.java:84)

Which points directly to the socket send function – this.socket.send(packet);

After placing a break point on my datagram packet I get the following info:

packet  DatagramPacket  java.net.DatagramPacket@52c4c57 
byte[]  #1248(length=16)    
offset  int 0   
length  int 16  
bufLength   int 16  
address Inet4Address    /192.168.0.101  
Static          
Inherited   
port    int 3889

I’m not clear on why this is occuring, if anyone could shed any light on the problem that would be great. My inital thoughts were perhaps one of the datagram packet elements was empty.

(Basic source)

ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(byteOut);

// Game type
out.writeInt(1);

// Client
out.writeInt(gamerToSend.getClientID());

// Position
out.writeFloat(gamerToSend.getX());
out.writeFloat(gamerToSend.getY());


DatagramPacket packet = new DatagramPacket
(
  byteOut.toByteArray(),
  byteOut.size(),
  gamerToSend.getInetAddress(),
  3887
);

this.socket.send(packet);

byteOut.close();
out.close();

INetAddress info: (Ip is correctly displaying destination machine)

address Inet4Address    /192.168.0.101  /192.168.0.101  
Static      
INADDRSZ    int 4   4   
serialVersionUID    long    3286316764910316507 3286316764910316507 
loopback    int 2130706433  2130706433  
IPv4    int 1   1   
IPv6    int 2   2   
preferIPv6Address   boolean false   false   
nameService InetAddress$1   java.net.InetAddress$1@5bf0cf51 java.net.InetAddress$1@5bf0cf51 
serialVersionUID    long    3286316764910316507 3286316764910316507 
addressCache    InetAddress$Cache   java.net.InetAddress$Cache@1ebafdff java.net.InetAddress$Cache@1ebafdff 
negativeCache   InetAddress$Cache   java.net.InetAddress$Cache@679801c  java.net.InetAddress$Cache@679801c  
addressCacheInit    boolean true    true    
unknown_array   InetAddress[]   #1266(length=1) #1266(length=1) 
impl    Inet6AddressImpl    java.net.Inet6AddressImpl@12c9b196  java.net.Inet6AddressImpl@12c9b196  
lookupTable HashMap "size = 0"  "size = 0"  
$assertionsDisabled boolean true    true    
Inherited               
hostName                
address int -1062731675 -1062731675 
family  int 2   2   
canonicalHostName               
caport  int 3889    3889    

Server source
http://pastebin.com/JCdjhFQM

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:19:04+00:00Added an answer on May 20, 2026 at 8:19 pm

    thanks for your help.

    It appears the InetAddress is corrupted somewhere as manually setting it to the remote machine like so:

    InetAddress addr = InetAddress.getByName("192.168.0.101");
    

    Works perfectly fine, so I have more debugging to do, but thats the problem.

    Again thanks for the assist!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Everytime I try to create the following table in MySQL command line: CREATE TABLE
I have the following code that returns HTTP error 400 everytime I try to
I have an asp page that loads a response user=exists everytime I try to
I am trying to open a Socket on Android but everytime I try I
I would like to overload a method with the @QueryParam but everytime I try
I cannot run kannel(an open source sms gateway) run properly. Everytime I try I
I try to send a Toast Message from a Thread to the UIThread when
So, I have this link, that should send an AJAX request everytime it is
I am trying to send an object in java over a physical network (not
I try to send a mail via php to an yahoo recipient. Every time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.