How can i send pointer to struct from java to c?

Hi
my native function expect to get pointer to struct as follow:
int sendTo(const struct sockaddr_in *lpTo)
when the c function prototype is as follow:
JNIEXPORT jint JNICALL Java_myProg_sr_SendTo(JNIEnv env, jobject sockaddr_in lpTo)
my question is :
should i send the native function jobject as i did and then create a new instance of (struct sockaddr_in *) in the native function and that initialize all struct fields from the jobject (java object wrapper) fileds ,
or
should i just send jlong value that i stored in my java program and that points to the (struct sockaddr_in *) address after casting to this type???

You are going to need to create a new instance of sockaddr_in and populate it's fields from the Java object. This is the safest thing to do. I haven't seen anywhere in the documentation that you can simply cast objects to C structs, only primitive values.
For more info on populating fields, try:
http://java.sun.com/docs/books/tutorial/native1.1/implementing/field.html
http://java.sun.com/products/jdk/1.1/docs/guide/jni/spec/functions.doc.html#16536

Similar Messages

  • How can I send pictures or email from my desktop to a cell phone?

    How can I send pictures or email from my desktop to a cell phone?
    I use Gmail for my emails.

    By sharing playlists you mean sending the list of song titles along with the songs themselves you can't.  That would violate Apple's contracts with the studios regarding sharing music, videos, books, etc.  Which is strictly forbidden. With the single exception that I am aware of which is Home Sharing.
    If you just want to share the list of song titles you could take a screen shot and email that.  Hold down the home button and press and release the power button.  The image is then stored in your camera roll.

  • How can I send an e-fax from my iMac

    How can I send an e-fax from my iMac to another iMac or a windown machine?

    Read the suggestions in the following threads: 
    https://discussions.apple.com/thread/3416189 
    https://discussions.apple.com/message/23679130#23679130 

  • How can I send files via Bluetook from my Tour to other phones?

    How can I send files via Bluetook from my Tour to other phones?
    I have even been able to pair to the other device, but I don't see the option to send/copy/move files through Bluetooth.
    I can only send my Address book via bluetooth.
    Please help!!

    Hi and Welcome to the Community!
    See this KB:
    KB05409 Transfer a file using Bluetooth technology between two BlackBerry smartphones
    Substitute, in the KB, the appropriate instructions for your other device in place of the KB section for the receiving device. Be aware that RIM only supports BT file transfer between BBs...with other devices is technically unsupported. But, it usually works, as long as the two devices are paired, trusted to each other, and each have all of the correct BT services enabled for the configuration of the other device.
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • How can I send a Powerpoint document from my Mac to a PC?

    How can I send a Powerpoint document from my Mac to a PC?

    As an attachment in the usual way.

  • How can a send a group email from ipad

    How can I send a group email from iPad

    You need a third party app. You can't create contacts groups in the built in mail app. Look at...
    http://solubleapps.com/mailshot/
    or
    http://www.redbits.com/iphone/groupemail/

  • How can i get the source code from java concurrent program in R12

    Hi 2 all,
    How can i get the source code from java concurrent program in R12? like , "AP Turnover Report" is java concurrent program, i need to get its source code to know its logic. how can i get its source code not the XML template?
    Regards,
    Zulqarnain

    user570667 wrote:
    Hi 2 all,
    How can i get the source code from java concurrent program in R12? like , "AP Turnover Report" is java concurrent program, i need to get its source code to know its logic. how can i get its source code not the XML template?
    Regards,
    ZulqarnainDid you see old threads for similar topic/discussion? -- https://forums.oracle.com/forums/search.jspa?threadID=&q=Java+AND+Concurrent+AND+Source+AND+Code&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • How can i send and recieve mail through java

    HI All,
    plz let me know how can i send and receive mail through java.
    Regards:
    sachin kakkar
    http://www.datamansoftwares.com

    Using java mail API..
    try to search the forum for java mail... you find many question and answer.
    use the left search textfield

  • How can i call forpro prg file from java

    Hai friends,
    I have a doubt,clear it.
    how can i call forpro prg file from java file
    by,
    N.Vijay

    Thanks to your reply,
    I have some print statements in my foxpro program file.
    Then i like to invoke that foxpro file from my java file
    This want i want..,
    by,
    N.Vijay

  • HT3529 How can I send a text thread from my iphone to my email?

    How can i send a text message thread from iphone to gmail?

    You can send a text message from your iPhone to Gmail by addressing the text to the email address.
    You can also Copy/Paste the a message from text to an email.
    See the iPhone User Guide for more info about copying and pasting.

  • How can I send a Nook book from my iphone to my computer?

    How can I move a Nook book from my iphone to my hp computer?

    Go here to download the nook app to your hp computer:
    http://www.barnesandnoble.com/u/nook-for-pc/379003591/
    Then download the book using your computer.

  • How can i send an email file from my ipad to my pc via ubs connection

    also how can i get day/date/ time displayed on my banner line

    The time should already be shown on the status bar, but you can't add the day and/or date to it - if you would like to have them then you coul leave feedback for Apple : http://www.apple.com/feedback/ipad.html
    If you want to copy an attachment from an email then you can't do that directly from the Mail app. If the email is still on your provider's server then you should be able to read the email on your provider's site via a browser on your computer and save it from there directly on your computer. Otherwise you will need to copy the file from the Mail app to another app on your iPad via the 'open in' function. Do you have an app on your iPad that supports the type of file that you want to copy ? How you then copy the file to your computer will depend upon what the app that you copy it to supports - different apps have different ways of copying their content to/from a computer e.g. via the file sharing section at the bottom of the device's apps tab when connected to iTunes, via your wifi network, dropbox etc

  • How can I Send song by email from ipad ?

    I mean from songs already existed in my Music.

    You can't. You can Gift a song in iTunes if you pay for it, but you can't send an existing song via email. If you could, people would be sharing purchased music all the time.

  • RE: how can i send my pictures back from my macbook to my iphone?

    I needed to reformat my macbook so I decided to back up my photos that was on my iphotos through my iphone which was successful. But when I want to put it back to my macbook, everytime i connect my iphone it's only allowing me to transfer the photos that i took from my iphone camera. How can I import the photos from my iphone that was originally from my macbook? The photos are in my iphone but iphotos cannot detect it.
    So basically, i transfer my photos from my macbook to my iphone, but now i want to put it back to my laptop but i cannot find the way to do it. pls help
    thanks!

    Hi Anne
    At the present time the iPhone is not a browseable device, disc mode is not enabled. This may change with a future firmware update allowing you to browse the iPhone from the desktop as you can with some of the iPods, however at the moment this is pure speculation. The only way I can think of transferring the photos back from your iPhone is to e-mail each one individually to yourself, then pick them up from your mail account on your macbook.
    Not the answer you want I know, but I can't think of any other way currently.
    Good luck
    FlatE

  • HT1688 how can I send my text messages from my iphone to my computer so I may print them out?

    How can I forward text messages from my iphone to my PC to print out?

    Easiest way is to use third-party software, like this, to extract them:
    http://www.wideanglesoftware.com/touchcopy/index.php

Maybe you are looking for

  • Error while Creation Compatible Unit Order

    Hi, I am generating Maintenance Order from Compatible Unit Design. I am able to generate Order for design type D i.e.standard design. But when i try for design type T i.e. Standard design template, I am getting the following error : - *"Assign to CU

  • Backup Macbook 10.5.8

    I have a MacBook with 10.5.8 processor and I would like to backup the computer with an external hard drive.  It is a Toshiba.  Can you tell me the steps I need to do to get Time Machine to backup my Mac? Thanks

  • Huge mobile data traffic on 4.3.1

    Hey, a few minutes ago I checked my usage and the traffic says 4,0 GB sent and received! I didn't even got 1,5 GB in a year and recently a reset the phone so that the counter was on zero. Now that I updated to 4.3.1 this appeared´. Does anyone notice

  • App title and entitlement to keep your publication title?

    If I was to launch a multi folio App with my company name as the App title, as I understand it once that App title has been approved by Apple the name will no longer be available to anyone, for all time. Also my App will also no longer be available o

  • What should I do to reset my password when I have forget my old password?

    I have forget my old password