Send and recieve 2 byte integer values.

hi,
basically i'm trying to allow my applet and servlet communicate using 2 byte signed integer values. but i haven't figured out how to store an integer value into a byte array of size 2, or unpack it once it gets there.
here's some code/psuedocode that i've done so far.
SERVLET:
ByteArrayOutputStream bst = new ByteArrayOutputStream(streamsize);
ServletOutputStream bout;
byte[] strm = new byte[streamsize];
byte[] dbyte = new byte[2];
int[] testarr = new int[10];
/* fill my testarr with values... */
bout = response.getOutputStream();
int l = 0;
for (int i = 0;i<arraysize;i++){
getDoubleByteFromInteger(dbyte,testarr)
strm[l++] = dbyte[0];
strm[l++] = dbyte[1];
bst.write(strm,0,streamsize);
bst.writeTo(bout);
APPLET:
/* connect to servlet and get binary stream */
bytecount = in.read(streamb);
byte[] db = new byte[2];
counter = 0;
while (cursor < bytecount){
db[0] = streamb[cursor++];
db[1] = streamb[cursor++];
array[counter++] = getIntFromByte(db);
the functions getIntFromByte and getDoubleByteFromInteger haven't been written, can anyone give me a little push? or tell me if this is something possible? thanks for any help
Matt

The primitive type short is a two-byte signed integer, so you really don't need to bother with byte arrays - just use DataOutputStream to write it (it has a method called writeShort) and DataInputStream to read it (with readShort()).
But anyway, getting an int from two bytes and getting two bytes from an int is easy with the bitwise operators:
int -> byte array
int i = yourInt;
byte[] b = new byte[2];
b[1] = (byte) (i >> 8);
b[0] = (byte) (i);
byte array -> int (unsigned)
int i = ((b[1] & 0xFF) <<8) + (b[0] & 0xFF);
byte array -> short -> int (signed)
short s = (short) ((b[1] & 0xFF) <<8) + (b[0] & 0xFF);
int i = s;

Similar Messages

  • I am a newbie to labview but have delt with plc's for the last 10 years. I would like to send and recieve certain integer, floating poin

    t, or binary files through the plc or micrologix communication port. This would allow me to build a front panel and change certain states of bits or retrieve data from certain files to display on the front panel. Please steer me in the right direction...I am a newbie to labview but have delt with plc's for the last 10 years. I would like to send and recieve certain integer, floating point, or binary files through the plc or micrologix communication port. This would allow me to build a front panel and change certain states of bits or retrieve data from certain files to display on the front panel. Please steer me in the right dir
    ection...

    t, or binary files through the plc or micrologix communication port. This would allow me to build a front panel and change certain states of bits or retrieve data from certain files to display on the front panel. Please steer me in the right direction...Another option is to talk to the PLC using Modbus. Several versions of Modbus drivers are available online--or I could send you the ones I use.
    The big thing to look at is exactly what you want to do in the end. If you are going to be able to use all the features of the DSC, by all means go for it. It will save you a lot of time.
    If however, all you want is a remote front panel for the PLC, the DSC might be overkill. Only you can say.
    Look at your entire application and where you can see your work going in the reasonable future.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Need to send and receive larger byte array

    I have a small WCF service, self hosted in a console app. On the same computer I have a client application. Both are running in the debugger in VS2008. The proxy code and the config file were generatred from the running service using svcutil.
    In one of the service calls, the service reads a pdf file and sends the contents as a byte array. The client receives the byte array, saves it as a pdf file, and displays it.
    Everything is fine for all other kinds of calls, and this one works fine also as long as the file is small (say 14K). But if the file is larger (say 84K), the client crashes (VHOST has stopped working).
    Is there some kind of setting that will allow me to send and receive larger byte arrays (> 100 K)?
    Thanks,
    Jon Jacobs
    In transmission, subatomic particles managed by professionals.
    No innocent electrons were harmed.

    Hi Jon,
    You'll want something like this to increase the message size quotas:
    <bindings>
    <basicHttpBinding>
    <binding name="basicHttp" allowCookies="true"
    maxReceivedMessageSize="20000000"
    maxBufferSize="20000000"
    maxBufferPoolSize="20000000">
    <readerQuotas maxDepth="32"
    maxArrayLength="200000000"
    maxStringContentLength="200000000"/>
    </binding>
    </basicHttpBinding>
    </bindings>
    The justification for the values is simple, they are sufficiently large to accommodate most messages. You can tune that number to fit your needs. The low default value is basically there to prevent DOS type attacks. Making it 20000000 would allow for a distributed
    DOS attack to be effective, the default size of 64k would require a very large number of clients to overpower most servers these days.
    If you're still getting this error message while using the WCF Test Client, it's because the client has a separate MaxBufferSize setting.
    To correct the issue:
    Right-Click on the Config File node at the bottom of the tree
    Select Edit with SvcConfigEditor
    A list of editable settings will appear, including MaxBufferSize.
    Note: Auto-generated proxy clients also set MaxBufferSize to 65536 by default.
    Let me know if this helped.
    Regards,
    Raghu

  • Outbound IDOC - Sender and reciever

    Hello SDNites,
    I have created a report pgm which is equipped to send an outbound IDOC i.e used FM 'MASTER_IDOC_DISTRIBUTE'. Can someone please tell me how do I decide my sender and reciever when populating the control record in this FM.
    I know sender will be my system and reciver will be third party system but can you please tell me what values need to be opulated there or

    Thanks for the information,
    Can you please give the info in following form,
    1. Partner profile configuration with the values in your system.
    2. Code snippet where control records are poulated for Outbound IDOC with the values you specified in step 1.
    This will help me in understanding the same.
    Regards,
    Abhi

  • I am new to the ethernet communicat​ion using labview. I do not have any hardware. I have two laptop i need to send and recieve the data via these 2 laptop using labview. Kindly help me on this.

    i am new to the ethernet communication using labview. I do not have any hardware. I have two laptop i need to send and recieve the data via these 2 laptop using labview. Kindly help me on this.
    Solved!
    Go to Solution.

    Hi thanks for the help.
    Actually i am trying to send 10 sine signals from server pc to client pc. So i will bundle 10 signals in server pc and send it and in client pc i am unbundling it and need to save in TDMS format.
    Till unbundling i was able to do. TDMS format it is saving only last value. I need to save all the values. Kindly help me on same. I am attaching both the VI.
    Attachments:
    Client.vi ‏62 KB
    Server.vi ‏252 KB

  • Since updating to iOS 6 I no longer can hear the send and recieve text sounds when texting

    Updated to IOS 6 yesterday and now I am having trouble hearing the text "swoosh" or whatever it is called while in a converstation the sound you hear when you send one or recieve one. Also when my phone is switched to vibrate mode when I receive a text message all my phone does is light up and it dosn't not vibrate which stinks cuz if it is my pocket I don't know if I'm getting a text message. I went into the message settings to try and set a vibrate tone for when recieveing a text and It won't even vibrate when I click on an option or click to create my own vibration pattern. My phone still however vibrates when I recieve an email or when someone calls me ect.... just not on texts and no sound when in a text conversation as in sent and recieved sounds. My sister, and both my parents updated to IOS 6 yesterday and they are having not probems of any sort? Anyone else have this problem and know of a solution? Ive already tried resetting my phone thinking maybe it was a glitch but still have the same problems.

    I figured out my problem...... I have custom text tones set up for certain ppl and had the default text tone set to "none" well with the iOS6 update it made it so if your default text tone is set on "none" then you won't hear what I call the send and recieve text sounds when in a converstation... if you change the default text tone to any text tone other than "none" you will get your send and recieve sounds back.... kinda annoying if you don't won't random texts from ppl waking you up... so I made a custon text tone that is called silence with just recording a few seconds of dead noise then edited it and turned all the sound levels down to 0 and set that as my default text tone.... now I have the send and recieve text sounds in a conversation and everything is fine! Sorry Nehucskter the first time I had this problem thats the first thing I did was reboot my phone.... first thing you do for everything lol....

  • I have my Dad's apple ID etc, but he has an iphone and i have an Ipod Touch then on IMessage i can read all the messages he recieves and sends and he can read all the messages i send and recieve how do i stop this?

    Hi
    I have my Dad's apple ID etc, but he has an iphone and i have an Ipod Touch then on IMessage i can read all the messages he recieves and sends and he can read all the messages i send and recieve how do i stop this? But i still want to send messages to him.
    Thank You

    . You do not need a seperate Apple ID. One one device you just need to go to Settings>Messages and add another/different Messaging email address and delete the common Apple ID address. Also see:
    MacMost Now 653: Setting Up Multiple iOS Devices For Messages and FaceTime

  • Sender and reciever tabs of a Business systems

    Hi,
    I use XI 3.0 TCC version.
    My doubt is reated Integration Directory.
    When i assign Business system XXXXXX.
    The sender and reciever tabs of the business systems are populated with some standard and user defined
    Name Namespace and Software component versions.
    and i want to know y does this happen.
    Thanks
    Pradeep

    Hi Pradeep,
      i have understood what is ur doubt.
    Suppose u want to create a Business system of type WebAS ABAP.
    When u create a BS it will ask for a Technical system and client associated with it.After filling this u can see the installed product and all the Software component associated with it.u can see this due to dependency.
    Thats why ..when u import the BS in ID .. u can see the SWCVs and the namespaces.
    Sometimes the BS is used as a sender and sometimes rcvr.
    Regards
    Biplab

  • My imessages are gone. i cant activate them now. When i go into send and recieve its only my e-mail address thats ticked and not my phone number ticked also. When i sign in with my apple ID it is ticked there. can anyone help me please.

    my imessages are gone. i cant activate them now. When i go into send and recieve its only my e-mail address thats ticked and not my phone number ticked also. When i sign in with my apple ID it is ticked there. can anyone help me please.

    Hi,
    Go to the iPhone
    GO to Settings > Messages
    Is the iPhone Number ticked to be enabled (It will be greyed out and not editable but should be On)
    If it is Off (Unticked remove the Apple ID)
    Place the iPhone in Airplane mode for a few minutes.
    Go back to Settings Messages and make sure the Message app Is Enabled overall.
    Check the iPhone Number is verifying.
    When Completed test by sending an iMessage to your Apple ID (Mac)
    If that works add back the Apple ID to the iPhone's Settings.
    Restart the Mac App and Accept the op ups that appear as to what the iPhone is using.
    9:52 pm      Friday; April 4, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Airplay disconnecting when sending and recieving a message

    I use Airplay on my iPhone to stream music from the music app to my Apple TV. When sending and recieving a message over Skype or Facebook, my phone disconnects from Airplay, pausing the music.
    Is this a common issue, and are there any known fixes, or do i just have to wait for Apple to fix this in a future update?

    That is silly - Facebook message notifications are tiny.  You can't provide some vague hand waving dismissal of the problem and blame network throughput.
    I have the same issue - it's obviously a bug with iOS or Facebook.  Airplay shouldn't disconnect every time a new message arrives.  If I don't have Facebook open the same messages still arrive in the background and airplay works fine.
    The issue is specific to a foreground app receiving notifications and then Airplay craps out.
    Come on Apple, fix this!

  • File and photo and video sending and recieving

    I have been able to send and recieve videos photos and files till today. i have the latest skype version. The only thing i did different today was when asked if i wanted to accept the file i said yes and ticked the box for "do not ask again'' ..can i reverse that? and will it solve my problem?..thank you 

    What version of Windows are you on (XP, Vista, Windows 7, Windows 8 )? Is it 32-bit or 64-bit?
    http://support.microsoft.com/kb/827218
    What is the version of Internet Explorer installed on your computer?
    In Internet Explorer go to Help -> About Internet Explorer.
    P.S. Please, don’t say that you are not using Internet Explorer. This is irrelevant. Skype depends on Internet Explorer.

  • My NEW ipod touch stopped sending and recieving messages!

    My NEW ipod touch stopped sending and recieving messages even though I am connected to the internet and all other internet apps are working just fine.  I am just replying to messages sent to me.  Any suggestions as to the solution?

    This one
    http://www.apple.com/support/itunes/

  • Sending and recieving photos

    Does anyone know how I get the capability to send and recieve photos using the IPhone, I have the 8GB and it is far from full?

    That would not work if I'm sending and receiving from a person without e-mail capability on their phone. I used to be able to take a picture with my phone and send it a friends cell phone, is that not an option?

  • SAP TDMS add on setup on central/control , sender and reciever systems

    I found that SAP TDMS is shipped in the following add-ons:
    DMIS: Contains general functions, for example for the process monitor and for the technical data transfer
    DMIS_CNT: Contains TDMS-specific functions and some of the process types
    DMIS_EXT: For various additional process types (reduction scenarios) for SAP TDMS; currently, it contains only the process   type for business process library
    DMIS_BSC: For the process types to be used with SAP BI or CRM systems
    DMIS_HR: For the process types to be used in the context of SAP Human Capital Management (HCM)
    I have read TDMS master guide under section 3.4.1 Setting up the TDMS Server. There is a reference to SAP Note 970531 which is for DIMS setup and there is also reference to SAP note 970532 which is for DMIS_CNT setup.
    I would like to know if DMIS_EXT,DMIS_BSC and DMIS_HR need to be setup on TDMS central/control server , sender and reciever or only need to be setup on central/control server for respective scenario realization.
    Best Regards
    Mohammed Ashraf

    All the add-on components need to be installed in all the system (sender, receiver, central, control) in the landscape.

  • Send and recieving emails

    Are there some VI's that give the posibility to send and reciev emails?

    The internet toolkit has vi's that allow you to send email pragmatically. It does not include vi's to receive emails. I did, however, find some utilities on NI's site that allows you to receive mail in the POP protocol. Both work well.

Maybe you are looking for

  • I have a Kindle and can't connect the WiFi. is this a Firefox problem?

    Ehrn I try to connect I get the message that Kindle can't connect. Also what is the router?

  • Re: Issue in Returning Goods from Production..!!!

    Dear SAP Experts, Good Day..!!! I want to take a return quantity say 145 from Receipt from Production.When we click the add button it shows error msg as cannot add # without incomplete selection of batch/serial numbers. How to resolve from this issue

  • Download to excel between two given dates

    Hi All, I already implemented Export to Excel funtionality in webdynpro java. Now i have a requirement to download the data to Excel only between two given dates. I am taking two dates from the user and based on that it should download data into exce

  • How to exclude tables from Schema level replication

    Hi All, I am currently trying to setup Oracle Streams (Oracle 11.1.0.6 on RHEL5) to replicate a schema from one instance to another. The basic schema level replication is working well, and copying DDL and DML changes without any problems. However the

  • About export database

    Hi Guys, If I want to export just two table into file from database, do I need to kill all other connection? Like make database single? Can I use oracle sqldeveloper to develop stored procedure? Thanks.