Another question?? being able to send byte arrays containing multiple types

Hi,
I have a question which I would really appreciate any help on.
I am trying to send a byte array, that contains multiple types using a UDP app. and then receive it on the other end.
So far I have been able to do this using the following code. Please note that I create a new String, Float or Double object to be able to correctly send and receive. Here is the code:
//this is on the client side...
String mymessage ="Here is your stuff from your client" ;
int nbr = 22; Double nbr2 = new Double(1232.11223);
Float nbr3 = new Float(8098098.809808);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(mymessage);
oos.writeInt(nbr);
oos.writeObject(nbr2);
oos.writeObject(nbr3);
oos.close();
byte[] buffer = baos.toByteArray();
socket.send(packet);
//this is on the server side...
byte [] buffer = new byte [5000];
String mymessage = null; int nbr = 0; Double nbr2 = null;
Float nbr3 = null;
mymessage = (String)ois.readObject();
nbr = ois.readInt();
nbr2 = (Double) ois.readObject();
nbr3 = (Float) ois.readObject();
My main question here is that I have to create a new Float and Double object to be able to send and receive this byte array correctly. However, I would like to be able to have to only create 1object, stuff it with the String, int, Float and Double, send it and then correctly receive it on the other end.
So I tried creating another class, and then creating an obj of this class and stuffing it with the 4 types:
public class O_struct{ 
//the indiv. objects to be sent...
public String mymessage; public int nbr; public Double nbr2;
public Float nbr3;
//construct...
public O_struct(String mymessage_c, int nbr_c, double nbr2_c, float nbr3_c){
my_message = my_message_c;
nbr = nbr_c;
nbr2 = new Double(nbr2_c);
nbr3 = new Float(nbr3_c);
Then in main, using this new class:
in main():
O_struct some_obj_client = new O_struct("Here is your stuff from your client", 22, 1232.1234, 890980980.798);
oos.writeObject(some_obj_client);
oos.close();
send code....according to UDP
However on the receiving side, I am not sure how to be able to correctly retrieve the 4 types. Before I was explicitely creating those objects for sending, then I was casting them again on the receiving side to retrieve then and it does work.
But if I create a O_struct object and cast it as I did before with the indiv objects on the receiving end, I can't get the correct retrievals.
My code, on the server side:
O_struct some_obj_server = new O_struct(null, null, null. null);
some_obj_server = (O_struct)ois.readObject();
My main goal is to be able to send 4 types in a byte array, but the way I have written this code, I have to create a Float and Double obj to be able to send and receive correctly. I would rather not have to directly create these objects, but rather just create one object and be able to send and receive the information on both ends
I might be making this more complicated than needed, but this was the only way I could figure out how to do this and any help will be greatly appreciated.
If there an easier way to do I certainly will appreciate that advise as well.
Thanks.

which forum should I be posting this on?Serialization.
To get you started...
public class O_struct implements Serializable {                                                                                                                                                                                                                                                                                   

Similar Messages

  • I just wrote about not being able to send messages on my IPad.Someone responded-thanks-I did what they said and now I have no sent mail category.Help!!!!

    I just wrote about not being able to send messages on my IPad.Someone wrote back,thanks,about going to settings,outgoing mail etc. and I did that.Now I have no sent mail category.Help.

    When you reset the password, you need to enter the password into the outgoing server setting again. I have reset my email passwords a couple of times and I had to enter the password into the outgoing server setting before I could send mail again.
    Did you try that? If you did try it, did you try sending an email? You can send yourself an email to test it.

  • I am not being able to send pictures via Bluetooth from my Samsung phone to my iPad mini and vice versa. So is there a setting or is it a compatibility issue ? Please help

    I am not being able to send pictures via Bluetooth from my Samsung phone to my iPad mini and vice versa. So is there a setting or is it a compatibility issue ? Please help

    You can also use a wireless flash drive.
    http://www.sandisk.com/products/wireless/flash-drive/

  • Can receive mail but stopped being able to send mail

    I can receive mail on my MacBook Pro, but, after 3:03PM on 9/26/2014 I stopped being able to send mail. I get the follingg dialog box.
    Interestingly enough the data in this dialog box is out of date. My ISP at this location is not Verizon and there is no mention of iCloud. Nonetheless mail has worked without incident at this location for two years. At my office where I have a MacPro (4.1), Verizon is the ISP but, I believe, iCloud is the other listed server. (Im not there right now, so I ca't check). Incoming and outgoing mail work perfectly at that location. Both computers are rurnning OS 10.8.5. I'd appreciate any insight anyone might Have,
    Thanks,
    Stephen

    Hello Stephen,
    If you are having issues with sending and receiving email, check out the first two articles to get it sorted out. Also look at the third link and look at the time at which you were having issues as it may be related to an outage of service. 
    iCloud: Troubleshooting iCloud Mail
    http://support.apple.com/kb/TS4002
    OS X Mail: Troubleshooting sending and receiving email messages
    http://support.apple.com/kb/ts3276
    Apple Services, Stores, and iCloud
    https://www.apple.com/support/systemstatus/
    Regards,
    -Norm G. 

  • Some texts not being able to send with iPhone 6 Plus 8.1

    I recently upgraded my iPhone 5 to the new iPhone 6 Plus. Since then, I have noticed some issues with iMessage. I have not had this problem with any of my other iPhones in the past. I am now experiencing problems when I text certain people I get an exclamation mark with a message saying that the message was not delivered. How do I fix this? This happens with a handful of contacts. Others go through just like normal with no problem. My iPhone 6 Plus is updated to the latest software.

    Mostly SMS. I had tried sending an employee an imessage earlier and it didn't go through, but he later replied and said that his phone was off during work. Others are SMS messages to non Apple devices that are not being able to send.

  • Not being able to send or recieve messages

    I own a galaxy s5 and the past few days I havent been able to send or recieve messages. When I try to send messages it gives me the message not sent notification. I can still call people and data is still working its just text messaging that isnt working. Ive looked at numerous discussions and have done everything theyve suggested but to no luck. If anyone can give me suggestions it would be greatly appreciated.

        jamjacov99 Being able to send and receive text is very important. Are you using the stock text app or a 3rd party text app such as handscent emojis,hangouts, ect? Also, we understnad that others have tried steps but please let us know exactly what has been tried becausewe can only see what you post here. If you haven't done so already, go into settings, app manager, all apps, text messaging, and clear data, clear cache, and force stop. Then retest.
    Sheritah_vzw
    Follow us on Twitter
    @VZWSupport

  • Send byte array argeument from pl/sql to java stored procedure?

    I have a java method that accepts an argument of type byte[].
    I want to define a call specification so that it can invoked from a sql statement.
    The Java Developer's Guide show how to map SQL data types to java types and classes, but it is unclear if I can map a SQL data type to an array.
    Does anyone know which SQL type to use to map to a byte array?
    I'm using Oracle 10.2, thus jvm 1.4.2.

    As soon as I posted this question, I saw the RAW to byte[] mapping listed in the documentation. How did I overlook it? Anyway, that what I needed.

  • How to send byte array and String values to servlet from Swing application

    Hi all,
    I am new to swing, servlet, and socket connection.
    I have swing application to draw images and some input data. I dont know to send to server.
    byte[] buf = baos.toByteArray();
    URL servletURL = new URL("http://10.70.70.1:8080/servlet/SaveImage)
    URLConnection conn = servletURL.openConnection();
    conn.setDoOutput(true);
    BufferedWriter out = new BufferedWriter( new OutputStreamWriter( conn.getOutputStream() ) );
    out.write(buf&a=aaaa&b=bbbbb);
    out.flush();
    out.close();
    can I do like this. Strings are received in server side perfect. but i cant get byte array data. Please help me.
    Thanks in advance.

    <img src="myservlet">
    In your myservlet:
    response.setContentType("image/jpeg");
    then write your image date via ImageIO that uses response output stream.

  • How to send byte array of image with 300dpi.

    Hello fiends
                       i am making an application in which i have to send the byte array of an image with 300dpi.
    so i am using image snapshot class for that and use that code.
                        var snapshot:ImageSnapshot = ImageSnapshot.captureImage(cnvParent,300);
                        var bdata:String = ImageSnapshot.encodeImageAsBase64(snapshot);
    but when i send that bdata to php end using httpService.The size at other end of image increases surprisingly.i means it will increase its actual height and actual width.so is there any way to overcome this increase in size when i bitmapped image at 300 dpi?
    if there any way then please tell me.waiting for your reply.
    Thanks and Regards
        Vineet Osho

    Thanks david for such a quick reply.the link is really helpful.So we have to calculate the screendpi thruogh our code and then set the height and width of image.is there any simple way to sort out my problem.i just want to print my image at 300dpi but i am using image snapshot class so its taking the snap of my container(image) and save the image at 96 dpi which is dpi of my screen(monitor).so is there any way or any class in flex through which i got the image at its original dpi.i am not stick on 300 dpi but i m getting image from backend through xml at 300dpi.thats why i want the byte array i am sending should be at 300dpi.i am totally confused now.so please help me.
    Thanks and regards
      Vineet osho

  • Sending byte array to server

    Does anyone know how to send a byte array to the server?

    What is contained in the byte array? Is it audio/video/image?
    If you can get a binary representation of it, you could probably
    convert it to Base64 and send it over as a string and reconvert to
    binary on the server.

  • Not being able to send iMessage to PHONE NUMBER, but able to send iMessage to E-MAIL ADDRESS

    My sister's iPhone's iMessage setting "You can be reached for messages at" is set to her PHONE NUMBER and her APPLE ID e-mail ADDRESS. When I send a text message to her APPLE ID e-mail ADDRESS it goes as an iMessage and she receives an iMessage. However, when I send a text message to her PHONE NUMBER it goes as a TEXT message from my phone but is received as an iMessage on her end. She is able to send an iMessage when she sends a text message to my phone number.
    Why is the text message to her PHONE NUMBER not going as an iMessage?

    So far, I must say iMessage has not been very reliable.  It has taken much longer time to send out or receive iMessages because it has to go through Apple server to relay the message.  It also does not keep the message at server to relay at a later time if the recipient is not on 3G data or wifi.
    If you go to your iPhone setting, under Messages, you will find that "Send As SMS" is turned on by default, meaning at any time if iMessage server is busy or has difficulty in relaying the message over to the recipient., your message will automatically be changed to regular SMS.  If you want to avoid that, you have to turn off "Send As SMS".  But by doing that, you may sometimes find messages not being delivered.

  • I am having issues with being able to send videos through text message after the update

    I have the motorola droid 4 and after the recent update, I am no longer able to change my video settings on my phone. I need to be able to change the quality to low to be able to send as mms, however the option is no longer there? I have went through settings and nothing gives me the option to record a video and send it through text. error says that the video can not be attached because it is too large.  can someone please assist me. The update was 4.1.2 version.

    I have the Droid 4, and the 4.1.2 OS; when I open the camera and switch to video, then tap the gear for settings, I can choose HD+ (1080), all the way down to 320x240 resolution (5 different choices for resolution)
    I can then go to that video in my gallery, and I have the share option there... how long is the video you are trying to send?  What is the total size of the file?  Perhaps the receiving party's phone cannot receive the video file?

  • Not being able to send messages from any of the messaging apps iPhone 3gs

    I have tried resetting the phone a couple of times, including a reboot , swithcing off the phone etc. But Im just not able to send messages on Whatsapp, Couple or anything of the sort. Im not facing problems while receivig emails, but NONE of my messaging applications work!
    Btw I upgraded to IOS 6 last week.
    Also is there a way I can downgrade?
    Any way I can fix this?
    This will be my last iphone, if Im not able to fix this soon.

    iOS: Troubleshooting Messages - Apple Support

  • One of my 4 Gmail accounts has stopped being able to send mail

    I have 4 gmail accounts.  I can send and receive on all 4 but 1.  This just started a couple of days ago.  I get an error message that pops up but it goes away so fast I cannot see what it is.  I have tried to screenshot it but I cant seem to get it.  My mail locks up as soon as it happens and the mail I was attempting to send stays as a "draft".
    I have searched the forums, and so far I have gone to google verified my settings to make sure somehting did not get messed up there.
    I have checked my 1 account against the other 3 accounts and they are identical.
    I have uninstalled and reinstalled that account i dont even know how many times at this point.
    I was starting to try and uninstall the mail app but got hung up doing that so gave up on that plan (I also read that it probaly would not help what I have going on)
    I logged into a different account on my iMac set up my mail on that account and having the same issue.
    The only thing i have done in the past couple of days was link my gmail account to a computer at this college I attend (when u pull up google can synch) I did that but am unsure how that would mess up anything if at all.
    Anyone else have any ideas?

    Update I finally was able to get a photo of the error I am getting. its says
    Unable to sign message
    An error occurred while trying to sign this message wtha  certificate from "[email protected]" Verify this certificate for this address is correct and that its private key is in your keychain.
    So how do I do that?
    I never took or messed with the keychain so I am unsure how to go about figuring that out.

  • One of my email addresses stopped being able to send mail.

    It closes the message as if to send it and then re-opens the window and freezes it. Whatsup?!?
    I have tried deleting the mailbox and re-creating it, but it doesn't work. I am using SSL on this mailbox. No problem receiving mail, just sending.
    Note: The email address works fine on my laptop -- the settings are identical (identical). ***?
    --Alone & Confused in Western Mass.

    Update I finally was able to get a photo of the error I am getting. its says
    Unable to sign message
    An error occurred while trying to sign this message wtha  certificate from "[email protected]" Verify this certificate for this address is correct and that its private key is in your keychain.
    So how do I do that?
    I never took or messed with the keychain so I am unsure how to go about figuring that out.

Maybe you are looking for