Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java/Perl Question

  • 24-05-2005 11:04AM
    #1
    Moderators, Education Moderators Posts: 1,699 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