4
j0n4s
6y

Is there a better way communicating between php and java than tcp? Because this was my first idea but i try everything on localhost and the request takes up to 3 seconds...

Comments
  • 1
    Unix sockets?
  • 0
    With unix sockets i just found some c code but no java or c++ code
  • 0
    Shared file, database, call command line script, print to screen and a user must type into a command prompt?
  • 0
    @No-one yes but how should i connect from my browser to java or c++
  • 1
    @nobes PHP is server side isn't it? You're not calling from the browser
  • 0
    @DasKoder i know.. i want to communicate with php and a process which runs on the server
  • 0
    @nobes
    Sockets are fast, much faster than tcp. Can't help you with c++ or java but is not much harder than coding for tcp sockets.
  • 0
    @nobes so, from the browser(JavaScript) to/from PHP to/from Java process on the server?

    If it's just a quick PoC:
    JavaScript (websocket - socket.io) PHP ( direct command line call) Java...

    Though it's not my area of expertise at all. I'm a Microsoft peon usually. I imagine there are user permission issues there. You can always use a message queue like rabbitmq if that's not overkill?

    https://stackoverflow.com/questions...

    (Edit)
    I'm a moron; experienced heads say use sockets... Go with what they say...
  • 0
    @nbamaral i'm already working with sockets
  • 0
    @DasKoder i'm using sockets but it's very slow
  • 2
    @nobes
    Network sockets. Have you tried Unix domain sockets? Think of it as pipes. Send data, get data back, pretty much the same without the tcp overhead.
    https://en.m.wikipedia.org/wiki/...
  • 2
    @nbamaral thanks works fine!
  • 2
    @nobes yeah, UNIX pipe are pretty easy to use
  • 1
    Have you tried rabbit mq?
  • 0
    @shellbug is this faster than unix domain sockets? Because Unix domain sockets are very fast like 0-1 ms
  • 2
    @nobes I would expect the sockets approach to be faster.

    Rabbitmq is the way you would go if you needed multiple workers to process the work from the from end. Your distributed, Microservice architecture...
Add Comment