How to communicate properly between java server and gamemaker studio client












0















I have created a very very basic java server with tutorials. The goal is to let gamemaker studio 2 clients connect and communicate with that server. I have more experience with GML.
So the server is starting(java) up and the client(GMS2) is connecting succesfully. I have buildin some checks to make sure. If the client send a message to the server, the server never gets it, until the clients disconnect.



this is the java code:






import java.net.*;
import java.io.*;

public class GameServer {

public static void main(String args) throws IOException {

ServerSocket serverSocket = new ServerSocket(6666);
Socket client = serverSocket.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter out = new PrintWriter(client.getOutputStream(), true);

out.println("hello gamemaker studio: "); //the clients receive this message

while(true) {

System.out.println("in while loop");//the server console prints this message

String string = in.readLine();//keeps stuck on this
//after client disconnect, all messages the client has sent are displayed in the console
System.out.println("reading string:" + string);
if (string == null) { break; }

out.println("we have received this answer: " + string );
System.out.println("stopped");
}

}

}





For some reason i don't know it is keeps stuck on this line:
String string = in.readLine();
I crafted a java client to test it. Everything works fine with a java client.
So there has to be something wrong with the gamemaker code










share|improve this question

























  • Does the client send anything before the server does?

    – jbx
    Dec 30 '18 at 0:36











  • Are you sure that the client flushes their output and that it contains a newline (which readLine() is expecting)?

    – Mick Mnemonic
    Dec 30 '18 at 0:56











  • No, the server sent first the hello message to the client, the client receives that message and displays it. @MickMnemonic In gamemaker i have this to send a message: buffer_seek(buff, buffer_seek_start, 0); buffer_write(buff, buffer_string, "this is a test"); network_send_raw(server, buff, buffer_tell(buff));

    – Timmy Verrept
    Dec 30 '18 at 1:17













  • I think you're not using the java part of the application correctly. I don't think that while should be there - I'm not experienced with Java, but I am with GameMaker, and I'm sure that way of sending messages sends a single packet (you can double check that with a packet sniffer). I'm doing it the same way and have made successful servers. Maybe try connecting with "packet-sender" as well (packetsender.com) so you can validate your Java server.

    – Rob Quist
    Jan 9 at 17:11
















0















I have created a very very basic java server with tutorials. The goal is to let gamemaker studio 2 clients connect and communicate with that server. I have more experience with GML.
So the server is starting(java) up and the client(GMS2) is connecting succesfully. I have buildin some checks to make sure. If the client send a message to the server, the server never gets it, until the clients disconnect.



this is the java code:






import java.net.*;
import java.io.*;

public class GameServer {

public static void main(String args) throws IOException {

ServerSocket serverSocket = new ServerSocket(6666);
Socket client = serverSocket.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter out = new PrintWriter(client.getOutputStream(), true);

out.println("hello gamemaker studio: "); //the clients receive this message

while(true) {

System.out.println("in while loop");//the server console prints this message

String string = in.readLine();//keeps stuck on this
//after client disconnect, all messages the client has sent are displayed in the console
System.out.println("reading string:" + string);
if (string == null) { break; }

out.println("we have received this answer: " + string );
System.out.println("stopped");
}

}

}





For some reason i don't know it is keeps stuck on this line:
String string = in.readLine();
I crafted a java client to test it. Everything works fine with a java client.
So there has to be something wrong with the gamemaker code










share|improve this question

























  • Does the client send anything before the server does?

    – jbx
    Dec 30 '18 at 0:36











  • Are you sure that the client flushes their output and that it contains a newline (which readLine() is expecting)?

    – Mick Mnemonic
    Dec 30 '18 at 0:56











  • No, the server sent first the hello message to the client, the client receives that message and displays it. @MickMnemonic In gamemaker i have this to send a message: buffer_seek(buff, buffer_seek_start, 0); buffer_write(buff, buffer_string, "this is a test"); network_send_raw(server, buff, buffer_tell(buff));

    – Timmy Verrept
    Dec 30 '18 at 1:17













  • I think you're not using the java part of the application correctly. I don't think that while should be there - I'm not experienced with Java, but I am with GameMaker, and I'm sure that way of sending messages sends a single packet (you can double check that with a packet sniffer). I'm doing it the same way and have made successful servers. Maybe try connecting with "packet-sender" as well (packetsender.com) so you can validate your Java server.

    – Rob Quist
    Jan 9 at 17:11














0












0








0








I have created a very very basic java server with tutorials. The goal is to let gamemaker studio 2 clients connect and communicate with that server. I have more experience with GML.
So the server is starting(java) up and the client(GMS2) is connecting succesfully. I have buildin some checks to make sure. If the client send a message to the server, the server never gets it, until the clients disconnect.



this is the java code:






import java.net.*;
import java.io.*;

public class GameServer {

public static void main(String args) throws IOException {

ServerSocket serverSocket = new ServerSocket(6666);
Socket client = serverSocket.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter out = new PrintWriter(client.getOutputStream(), true);

out.println("hello gamemaker studio: "); //the clients receive this message

while(true) {

System.out.println("in while loop");//the server console prints this message

String string = in.readLine();//keeps stuck on this
//after client disconnect, all messages the client has sent are displayed in the console
System.out.println("reading string:" + string);
if (string == null) { break; }

out.println("we have received this answer: " + string );
System.out.println("stopped");
}

}

}





For some reason i don't know it is keeps stuck on this line:
String string = in.readLine();
I crafted a java client to test it. Everything works fine with a java client.
So there has to be something wrong with the gamemaker code










share|improve this question
















I have created a very very basic java server with tutorials. The goal is to let gamemaker studio 2 clients connect and communicate with that server. I have more experience with GML.
So the server is starting(java) up and the client(GMS2) is connecting succesfully. I have buildin some checks to make sure. If the client send a message to the server, the server never gets it, until the clients disconnect.



this is the java code:






import java.net.*;
import java.io.*;

public class GameServer {

public static void main(String args) throws IOException {

ServerSocket serverSocket = new ServerSocket(6666);
Socket client = serverSocket.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter out = new PrintWriter(client.getOutputStream(), true);

out.println("hello gamemaker studio: "); //the clients receive this message

while(true) {

System.out.println("in while loop");//the server console prints this message

String string = in.readLine();//keeps stuck on this
//after client disconnect, all messages the client has sent are displayed in the console
System.out.println("reading string:" + string);
if (string == null) { break; }

out.println("we have received this answer: " + string );
System.out.println("stopped");
}

}

}





For some reason i don't know it is keeps stuck on this line:
String string = in.readLine();
I crafted a java client to test it. Everything works fine with a java client.
So there has to be something wrong with the gamemaker code






import java.net.*;
import java.io.*;

public class GameServer {

public static void main(String args) throws IOException {

ServerSocket serverSocket = new ServerSocket(6666);
Socket client = serverSocket.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter out = new PrintWriter(client.getOutputStream(), true);

out.println("hello gamemaker studio: "); //the clients receive this message

while(true) {

System.out.println("in while loop");//the server console prints this message

String string = in.readLine();//keeps stuck on this
//after client disconnect, all messages the client has sent are displayed in the console
System.out.println("reading string:" + string);
if (string == null) { break; }

out.println("we have received this answer: " + string );
System.out.println("stopped");
}

}

}





import java.net.*;
import java.io.*;

public class GameServer {

public static void main(String args) throws IOException {

ServerSocket serverSocket = new ServerSocket(6666);
Socket client = serverSocket.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter out = new PrintWriter(client.getOutputStream(), true);

out.println("hello gamemaker studio: "); //the clients receive this message

while(true) {

System.out.println("in while loop");//the server console prints this message

String string = in.readLine();//keeps stuck on this
//after client disconnect, all messages the client has sent are displayed in the console
System.out.println("reading string:" + string);
if (string == null) { break; }

out.println("we have received this answer: " + string );
System.out.println("stopped");
}

}

}






java game-maker-studio-2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 30 '18 at 1:22







Timmy Verrept

















asked Dec 30 '18 at 0:14









Timmy VerreptTimmy Verrept

11




11













  • Does the client send anything before the server does?

    – jbx
    Dec 30 '18 at 0:36











  • Are you sure that the client flushes their output and that it contains a newline (which readLine() is expecting)?

    – Mick Mnemonic
    Dec 30 '18 at 0:56











  • No, the server sent first the hello message to the client, the client receives that message and displays it. @MickMnemonic In gamemaker i have this to send a message: buffer_seek(buff, buffer_seek_start, 0); buffer_write(buff, buffer_string, "this is a test"); network_send_raw(server, buff, buffer_tell(buff));

    – Timmy Verrept
    Dec 30 '18 at 1:17













  • I think you're not using the java part of the application correctly. I don't think that while should be there - I'm not experienced with Java, but I am with GameMaker, and I'm sure that way of sending messages sends a single packet (you can double check that with a packet sniffer). I'm doing it the same way and have made successful servers. Maybe try connecting with "packet-sender" as well (packetsender.com) so you can validate your Java server.

    – Rob Quist
    Jan 9 at 17:11



















  • Does the client send anything before the server does?

    – jbx
    Dec 30 '18 at 0:36











  • Are you sure that the client flushes their output and that it contains a newline (which readLine() is expecting)?

    – Mick Mnemonic
    Dec 30 '18 at 0:56











  • No, the server sent first the hello message to the client, the client receives that message and displays it. @MickMnemonic In gamemaker i have this to send a message: buffer_seek(buff, buffer_seek_start, 0); buffer_write(buff, buffer_string, "this is a test"); network_send_raw(server, buff, buffer_tell(buff));

    – Timmy Verrept
    Dec 30 '18 at 1:17













  • I think you're not using the java part of the application correctly. I don't think that while should be there - I'm not experienced with Java, but I am with GameMaker, and I'm sure that way of sending messages sends a single packet (you can double check that with a packet sniffer). I'm doing it the same way and have made successful servers. Maybe try connecting with "packet-sender" as well (packetsender.com) so you can validate your Java server.

    – Rob Quist
    Jan 9 at 17:11

















Does the client send anything before the server does?

– jbx
Dec 30 '18 at 0:36





Does the client send anything before the server does?

– jbx
Dec 30 '18 at 0:36













Are you sure that the client flushes their output and that it contains a newline (which readLine() is expecting)?

– Mick Mnemonic
Dec 30 '18 at 0:56





Are you sure that the client flushes their output and that it contains a newline (which readLine() is expecting)?

– Mick Mnemonic
Dec 30 '18 at 0:56













No, the server sent first the hello message to the client, the client receives that message and displays it. @MickMnemonic In gamemaker i have this to send a message: buffer_seek(buff, buffer_seek_start, 0); buffer_write(buff, buffer_string, "this is a test"); network_send_raw(server, buff, buffer_tell(buff));

– Timmy Verrept
Dec 30 '18 at 1:17







No, the server sent first the hello message to the client, the client receives that message and displays it. @MickMnemonic In gamemaker i have this to send a message: buffer_seek(buff, buffer_seek_start, 0); buffer_write(buff, buffer_string, "this is a test"); network_send_raw(server, buff, buffer_tell(buff));

– Timmy Verrept
Dec 30 '18 at 1:17















I think you're not using the java part of the application correctly. I don't think that while should be there - I'm not experienced with Java, but I am with GameMaker, and I'm sure that way of sending messages sends a single packet (you can double check that with a packet sniffer). I'm doing it the same way and have made successful servers. Maybe try connecting with "packet-sender" as well (packetsender.com) so you can validate your Java server.

– Rob Quist
Jan 9 at 17:11





I think you're not using the java part of the application correctly. I don't think that while should be there - I'm not experienced with Java, but I am with GameMaker, and I'm sure that way of sending messages sends a single packet (you can double check that with a packet sniffer). I'm doing it the same way and have made successful servers. Maybe try connecting with "packet-sender" as well (packetsender.com) so you can validate your Java server.

– Rob Quist
Jan 9 at 17:11












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53974336%2fhow-to-communicate-properly-between-java-server-and-gamemaker-studio-client%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53974336%2fhow-to-communicate-properly-between-java-server-and-gamemaker-studio-client%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Mossoró

Error while reading .h5 file using the rhdf5 package in R

Pushsharp Apns notification error: 'InvalidToken'