On Jun 21, 2009, at 10:19 PM, circle19851127 wrote:
Hello,everyone:
I'm so sorry for my terribal English ,and I'll work on that.
I am a green on JNA.Lately I met a problem when I was working on
this.My question is like that:
The DLL is written by C++ which I know nothing about.The
function descriped in the .h file is
int DUABind(struct UserInfo* puserinfo,
char* dsaip_address,
int port_no,
SOCKET* psock,
int bindseconds)
I wrote the follow code in Java:
int DUABind(TUserInfo.ByReference puserinfo,
ByteByReference[] dsaip_address ,
You either want String here (if dsaip_address is "const char*") or
byte[] (if the function writes to the given buffer).
int port_no,
Socket psock,
int bindseconds);
P.S.:
public class TUserInfo extends Structure implements Invariable{
public static class ByReference extends TUserInfo implements
Structure.ByReference{}
public static class ByValue extends TUserInfo implements
Structure.ByValue{}
public byte[] Name = new byte[20]; //name
public byte[] Password = new byte[20]; //password
}
There is 9 results it maybe return.I got a '3' which means
"connect failed!".If it return a '0' which means connet is
successful,it will init the forth parameter 'SOCKET* psock'.So I
defined a 'Socket psock = null; ' in java project .I don't know
where I was wrong . Is there another type which is for SOCKET* in
JNA? or other mistake? I really don't know.
Because it's really a little enmergency,please help me !
Thank you very much!
Passing psock = null is the same as passing NULL to the native
function. The declaration asks for a pointer to struct, so you should
pass a Structure object of the appropriate type (unless it's valid to
pass "null").