I consider myself fairly experienced in both JAVA and GML but can't seem to figure this one out. I have done client-sever programming with GML/39dll and with JAVA sockets in the past, but they have always been GameMaker to GameMaker or JAVA to JAVA. I want to create the game client in GameMaker(for simplicity) and the server in JAVA(for speed). So last night I wrote a simple server and client and got them to connect. The problem is actually sending data. I wrote the number 2 as a byte into the buffer (GameMaker-39dll Client) but on the JAVA end(just using the standard java.net.Socket class) I got the value 5. After abit of googling I came across this post: Link. It said:
Dont use Java's own Socket API for server with 39dll for client.
Will be difficult to set up.
Instead, use JNI (Java Native Interface) to call 39dll functions from Java.
Just recompile the 39dll source with JNI support (jni.h). Then call 39dll functions from Java and use the same commands as you would in GM to set up a server to which your Game Client (which also uses 39dll)
can communicate.
If you scroll down abit you will see this:
I don't know if anyone is still interested in it...
I made it yesterday, for myself.
http://adf.ly/373209/39dll-4-java
Just unzip the archive, and include both JARs in the Build Path of your Java project.
Just a simple test code, doesn't use sockets, but pasted it here so you'll know how to use it:import java.io.File; import pl.org.shocker.lib39dll.*; public class Main { public static void main(String[] args) { Lib39dll.libInit(); try { System.out.println(Lib39dll.myHost()); System.out.println(Lib39dll.myMAC()); File file = new File("asdf.dat"); if (file.exists()) { LibFile f = LibFile.open(file,EFileMode.Read); Buffer.def.clear(); f.read(); f.close(); System.out.println(Buffer.def.readString()); System.out.println(Buffer.def.readUInt()); } else { Buffer.def.clear(); Buffer.def.writeString("lolzord"); Buffer.def.writeUInt(666); LibFile f = LibFile.open(file,EFileMode.Write); f.write(); f.close(); } } catch (Lib39dllException e) {e.printStackTrace();} Lib39dll.libDeinit(); } }EDIT: Btw. Yes, I know how old the topic is.
Now to make it work with the .dylib...
So, great. I downloaded the zip archive and added it to my java program. But I get an error upon running my program (I'm using netbeans btw).
Then it goes and prints the stack trace. Here is my code:Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library '39dll': The specified module could not be found.
package server;
import java.util.logging.Level;
import java.util.logging.Logger;
import pl.org.shocker.lib39dll.*;
public class Server {
public static void main(String[] args) {
Lib39dll.libInit();
System.out.println("Init");
try {
while (true) {
Socket socket = Socket.listenTCP(Constants.SERVER_PORT, Constants.MAX_CLIENTS, EConnectMode.NonFreezing);
}
} catch (Lib39dllException ex) {
Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
}
Lib39dll.libDeinit();
}
}"System.out.println("Init");" is never executed and the problem is with the libInit(); method. Now, it tells me it cant find the 39dll file and I have tried a few things. The post says to place 39dll.java in the build path of your project, which I did but I still get the error. I also tried sticking 39dll.dll in there but nothing changed.So, my question is has anyone gotten 39dll and JAVA sockets to communicate properly? Or has anyone gotten JAVA to utilize 39dll and communicate with gamemaker in that way? All help is appreciated. If I need to go find a java forum, just let me know... I posted here because there are more GameMaker programmers that have JAVA knowledge then the other way around.
Edited by Macraze, 28 July 2011 - 09:42 PM.











