[zeromq-dev] IPC communication between C and JAVA application
Federico Serale
federico.serale at gmail.com
Mon Jan 28 10:25:00 CET 2013
I added socket.setLinger(0) but not changed anything.
I realized that the problem is in the client because when I start the
server I see that the file is created, but when I start the client the
file is not modified.
> One way for this to happen is for the client to call socket.setLinger(0)
> before the call to socket.connect(). I see that's not what you're
> doing, but perhaps the default linger is 0 instead of -1 in your build
> environment?
>
> You could also `ls -l /tmp/test` while the server is running to check
> whether it was created and when it was last modified. This, combined
> with running the client or server alone, might help to find out what's
> going on.
>
> On Sun, Jan 27, 2013 at 04:04:04PM +0100, Federico Serale wrote:
>> i'm on a ubuntu OS and i am trying to make a communication between C
>> and JAVA with IPC.
>>
>> i created a server In C, and this is the code:
>>
>> #include "testutil.hpp"
>> #include <stdio.h>
>>
>> int main () {
>> void *ctx = zmq_init (1);
>> assert (ctx);
>>
>> void *sb = zmq_socket (ctx, ZMQ_REP);
>> assert (sb);
>> int rc = zmq_bind (sb, "ipc:///tmp/test");
>> assert (rc == 0);
>>
>> /* Create an empty ØMQ message */
>> zmq_msg_t msg;
>> rc = zmq_msg_init (&msg);
>> assert (rc == 0);
>>
>> /* Block until a message is available to be received from socket */
>> rc = zmq_recv (sb, &msg, 0, 0);
>> assert (rc == 0);
>> printf("%s", msg);
>> /* Release message */ zmq_msg_close (&msg);
>>
>>
>> rc = zmq_close (sb);
>> assert (rc == 0);
>>
>> rc = zmq_term (ctx);
>> assert (rc == 0);
>> return 0;
>> }
>>
>>
>>
>> and i created a client in JAVA, this is the code:
>>
>> import org.zeromq.ZMQ;
>>
>> public class Main{
>> public static void main(String[] args){
>> // Prepare our context and socket
>> ZMQ.Context context = ZMQ.context(1);
>> ZMQ.Socket socket = context.socket(ZMQ.REQ);
>>
>> System.out.println("Connecting to hello world server...");
>> socket.connect ("ipc:///tmp/test");
>>
>> String requestString = "Hello\n";
>> byte[] request = requestString.getBytes();
>> request[request.length-1]=0; //Sets the last byte to 0
>> // Send the message
>> socket.send(request, 0);
>>
>> }
>> }
>>
>> The client application seems that ends successfully, while the
>> server application is blocked waiting for reception of a message.
>> What could be the problem?
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list