Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java/Perl Question

  • 24-05-2005 10:04am
    #1
    Moderators, Education Moderators Posts: 1,863 Mod ✭✭✭✭


    #
    # connect to player
    #
    
    if(SOCKNAME =~ m/^\d+$/) {
    	$socket = IO::Socket::INET->new(Type => SOCK_STREAM, PeerAddr => SOCKHOST, PeerPort => SOCKNAME);
    } else {
    	$socket = IO::Socket::UNIX->new(Type => SOCK_STREAM, Peer => SOCKNAME);
    }
    

    This is a pieve of perl code that opens a socket on the localhost at a specified port.

    The first part uses INET which I can program in java, the second part uses
    some UNIX socket thingy that I'm not familiar with. There is a .sock file that this perl program calls and communicates with.

    What I want to know is, how do I write a java program that opens a socket to a file in Linux ? /tmp/jd.sock is the file. I'm guessing this is the method that the perl program uses to communicate with the other perl program.

    jd is a mp3player, and you can connect to it and queue up songs and cancel songs etc.


    Ok not a very well organised post but you should get the jist and if you could help me that would be great !

    Thanks,

    Ro.


Comments

  • Registered Users, Registered Users 2 Posts: 441 ✭✭robfitz


    Slaanesh wrote:
    the second part uses some UNIX socket thingy that I'm not familiar with.

    I've just looked and UNIX sockets are not support by standard java.

    UNIX sockets are used for interprocess communication on unix like systems, search AF_UNIX o AF_LOCAL on google to find more information.

    You should be able to configure the server part of the program to use normal IP sockets and that should work just fine with your java program.


  • Closed Accounts Posts: 1,719 ✭✭✭Ruaidhri


    would it be possible to use JNI to do the task you want? I'm not too familiar with JNI but i'd imagine it would allow you to access the native unix calls you need to access. can anyone clear this up for me?


  • Registered Users, Registered Users 2 Posts: 441 ✭✭robfitz


    Ruaidhri wrote:
    would it be possible to use JNI to do the task you want?

    Yes JNI would work, I believe I saw a few projects when I was searching before.


Advertisement