Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7681231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:17:41+00:00 2026-05-31T18:17:41+00:00

I have a game server application (Java) and want to have PHP communicate directly

  • 0

I have a game server application (Java) and want to have PHP communicate directly with it. For example, sending a command (from PHP) that returns a list of users. Kicking a specific player from the game server etc.

How can I interface Java with PHP? I’ve thought of a few things, would any of these work?

  • Java game server running an additional service (e.g. HTTP server) for remote control (on another port)
  • PHP and Java communicating via. database – e.g. Java checks table for commands to-do
  • Java and PHP both connecting to an additional service that interfaces the two
    • Java connects (socket etc.) to server
    • PHP connects to server
    • Server handles traffic either way

Which would be best and how would I go about implementing that method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:17:43+00:00Added an answer on May 31, 2026 at 6:17 pm

    The exact conditions of the problem you are trying to solve are not clear to me. But let me suggest a few scenarios, hopefully at least one of which addressess your problem.

    First of all, I am assuming both your java code and php code reside on a web server, which means they can be executed using standard http protocol. In php, that simply means that you have a .php web page that can use the standard $_REQUEST object and standard output methods (such as header and echo). Similarly, in java that means your code resides in a servlet or jsp and uses the standard request and response objects.

    I will discuss methods for sharing global data between java and php below, but for the moment let’s not worry about that. Let’s discuss 3 possible communication scenarios:

    1) Your game is running in a browser (or another program that uses http to communicate with your web server) and wants to call the java and php separately. In that case, your game code simply calls the appropriate url, using the standard GET or POST methodology for passing in arguments, and processing the response text returned by your code. However, I suspect that scenario does not answer your question.

    2) If you want your java to call your php, then you can use the java.net classes (such as URL) to call your php page. The java tutorial has a good explanation on how to do this: http://docs.oracle.com/javase/tutorial/networking/urls/index.html

    3) Similarly, if you want your php to call your java, there are several possibilities. The most general one is the CURL php extension. There is a good discussion on how to do this here: How to send a GET request from PHP? BTW, the Java Bridge mentioned above uses this methodology.

    Ok, so now how do we share data between java and php? If there is no need to share global data between your code, then, as mentioned above, you can use http to pass in request parameters and send back text output responses (using json, xml, or whatever else you like). However, if there is global data that needs to be shared, that is a bit more complicated. You need to use the server file system to share the data, as there is no memory sharing between java and php (at least that I know of). Since both java and php can read and write files, there is no problem writing the code. However, there is the problem of concurrency. If it is possible for several pieces of code to access and modify the global data at exactly the same time, then you have to worry about that, because otherwise data changes could be lost or the data could get corrupted. So the easiest solution, as suggested above, is to use a database, because the database software takes care of the concurrency for you. Otherwise, you have to have some sort of file locking mechanism, which is doable, but probably not worth the effort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a java game app that uses sockets to communicate with each other.
I have a game server which is made in Java. I want to make
I have a game server (WoW). I want my players to download my custom
I have a game server that spawns a thread for each client with forkIO.
Let's say I have an application that is guaranteed to overwhelm one server even
I have written a game in PlayN, which has to communicate with a JavaEE-Server
We have application that involves C++ socket server, Flash client that communicates with C++
I have a Java application that parses files and stores the data I need
I have a distributed application which polls for commands from a central server and
I have an air application that I'd like to turn into a multi-player game.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.