passing C network structures in JNI
1 posts in topic
Flat View  Flat View

Posted By:   Divya_G
Posted On:   Tuesday, March 23, 2004 04:39 AM

hi.i am doing a networking project in which i wrote a C prog using winsock2.h.
among the several functions i wrote in the C file,one of them has to take SOCKADDR_IN as its parameter.
when i declared the function along with its parmeters as a native method in the java file,
the java compiler is giving
"unresolved symbol--SOCKADDR_IN" error..
so can u please help me to access the C network structure in java using JNI as soon as possible??

Re: passing C network structures in JNI

Posted By:   R_H  
Posted On:   Tuesday, March 23, 2004 02:13 PM

c style pointers are accesible in java as long primitive types, but this can't be used directlly as pointer for mem manipulation, this value can be used as "storage of pointer" for this mem area.

Good pattern is create "jni based" support object for SOCKADDR_IN manipulation - with this long value in constructor. This object can be then safe envelope for this area manipulation, and anyway - take care that only this object can alloc/free this mem. piece to prevent mem colisions. ( do free in finalize )
About | Sitemap | Contact