473,419 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

How to use checksum in a DatagramPacket in java?

108 100+
For instance I have the following codes:
Expand|Select|Wrap|Line Numbers
  1. public void clients(){
  2.  
  3.      try
  4.      {           address =InetAddress.getByName("localhost");
  5.                  byte[] SBM_client_array_receive=new byte[256];
  6.                  byte[] SBM_client_array_send;
  7.                  String SBM_login="SBM login "+"username"+""+"passowrd";
  8.                  SBM_client_array_send=SBM_login.getBytes();
  9.                  System.out.println("Sending .."+SBM_login);
  10.                  SBM_client_socket=new DatagramSocket();
  11.                  SBM_packet_send=new DatagramPacket(SBM_client_array_send,SBM_client_array_send.length,address,8000);
  12.                  SBM_client_socket.send(SBM_packet_send);
  13.  
  14.                  SBM_client_array_receive=new byte[256];
  15.                  SBM_packet_receive = new DatagramPacket(SBM_client_array_receive, SBM_client_array_receive.length);
  16.                  SBM_client_socket.receive(SBM_packet_receive);
  17.  
  18.  
  19.  
  20.  
  21.      }
  22.   catch(IOException e)
  23.              {
  24.         System.err.println(e.getMessage());
  25.  
  26.  
  27.                           // TODO add your handling code here:
  28.               }
  29.  
  30. }
  31.  
If I have the following codes,how can I modify it such that I can include a checksum in the datagrampacket?

Are there any java methods to do that ?
Oct 18 '10 #1
0 1140

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: GujuBoy | last post by:
is there a built-in function that does a "checksum" on a file...basicly counts the bytes and computes a 16-bit checksum for each given FILE. this is the like the "sum" command in unix
2
by: pradeep | last post by:
I have 2 data files, DATA1 and DATA2 , both same. My task is to: Open DATA1, compute the checksum and put it in the end of the file(don't bother about boundary conditions).close DATA1 Open...
2
by: Abby | last post by:
I need to do 8 bits 2's complement checksum, so I wrote code in order to see if the checksum calculation is correct. ===========================================================================...
1
by: Unebrion | last post by:
Alright im working on a program that prints out user imput in a frame, along with a barcode.. it is like the front of an envelope. Here is the description for the program. This...
0
by: hotrod7262 | last post by:
I'm trying to accept UDP multicast XML messages and parse them. The current way I'm doing so is by creating a new File for each message and then calling parser.parse(filename.xml) This way works....
6
by: duit889 | last post by:
how to using java class in php? thank you
1
by: duit889 | last post by:
this is my java class: filename : HGO.class and HGO.java Script: package nano; import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import...
1
eyeofsoul
by: eyeofsoul | last post by:
i have build the gui but i am having problem with implementing the tcp/udp. can somebody help me. i have server and client. the server can chat with the client. when i tried to to use the udp of tcp...
3
by: RockyIV | last post by:
I want to sent a .dat file from the server to the client and have the client put it in an array and display it. My problem is on the server end but i jus dont know what to do. can anyoner please help...
1
by: pb2000 | last post by:
Hello, I work with Client/Server example as below: public class Client { public static void main(String args) throws IOException, ClassNotFoundException { InetAddress address =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.