I have written a code which used to send data that was saved in my mysql database, through ethernet using UDP protocol, everything worked fine until i sent fewer data(25 rows), when i started sending data in huge amount(100 rows) it used to display Java Result: -1073740791 and would stop the running code. can somebody help e please.

 try {
            InetAddress src = null;
            InetAddress dest = null;
            if (pack instanceof IPPacket) {
                IPPacket ipp = (IPPacket) pack;
                src = ipp.dst_ip;
                dest = ipp.src_ip;
            System.out.println("src ip: " + src);
            System.out.println("dest ip: " + dest); 

            EthernetPacket etherSrc = ((EthernetPacket) pack.datalink);
            byte[] gwmac = null;
            gwmac = etherSrc.src_mac;
            System.out.println("dest mac : " + gwmac);
            JpcapSender sender = JpcapSender.openDevice(devices[index]);

            UDPPacket sendPacket = new UDPPacket(55000, 61000);           

            sendPacket.setIPv4Parameter(0, false, false, false, 0, false, false, false, 0, 1010101, 100, IPPacket.IPPROTO_UDP,
                    src, dest);
            String outData = sendData(pack);
            sendPacket.data = outData.getBytes();
            System.out.println("string sent =" + sendPacket.data);

            EthernetPacket ether = new EthernetPacket(); //get ethernet packet
            ether.frametype = EthernetPacket.ETHERTYPE_IP; //set frame type as IP
            ether.src_mac = devices[index].mac_address;
            System.out.println("source MAC address =" + ether.src_mac);
            ether.dst_mac = gwmac;
            System.out.println("destination MAC address =" + gwmac);
            for (byte b : ether.dst_mac) {

                System.out.print(Integer.toHexString(b & 0xff) + ":");
            sendPacket.datalink = ether;
            sender.sendPacket(sendPacket); //error comes at this line
        } catch (UnknownHostException ex) {
            Logger.getLogger(Net.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, ex);

sendPacket holds the data that is been extracted from the mysql database

3 Years
Discussion Span
Last Post by PreethiGowri

Just a guess, but... you seem to be sending all the data as a single packet, so maybe you are creating a UDP packet that's too big for something in your network?


According to my knowledge we can send a max. of 65507 Bytes = 63.97168KB(correct me if im wrong) accuratly at once using UDP protocol. and i'm sending a data size of 40KB at once and i still get the above error.


That is the largest Safe UDP Packet Size on the Internet. Can i know how much data can be sent with or without loss in a single UDP packet??


AFAIK there is no single definitive correct answer to that question. The link I gave you has some pretty good answers. It's not just about the internet, it's any IP network. Very sorry, I don't have the expertise to add anything to that. Maybe someone else can help, or mabe you will get a better answer from the DaniWeb Networking forum


so basically, if it works perfectly with 25 rows: when you have to send 100, split it into parts, and send them seperately.


yes, i'm doing that.. :) but i want to know, why that error code is been generated, and why i am not able to send huge amount of data at once.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.