Hi Fsbio! 2011/9/26 Fábio Costa <[email protected]>: > I was trying to make a liquidsoap java socket communicator, i fought a few > days with this issu so i am posting here the code to anyone that finds it > useful.
Thanks for this code! There is a dedicated section on our wiki for user snipets, maybe you want to add it there: http://wiki.sourcefabric.org/display/LS/User+Snippets Romain > The following code use JUNIX for the comunication > http://code.google.com/p/junixsocket/ > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > import java.io.BufferedOutputStream; > import java.io.BufferedReader; > import java.io.DataInputStream; > import java.io.File; > import java.io.IOException; > import java.io.InputStream; > import java.io.InputStreamReader; > > import org.newsclub.net.unix.AFUNIXSocket; > import org.newsclub.net.unix.AFUNIXSocketAddress; > > > public class TestJunix { > public static void main(String[] args){ > try { > File socketFile = new > File("/home/fabio/workspace/liquidsoap/socket_teste"); > AFUNIXSocket sock; > sock = AFUNIXSocket.newInstance(); > sock.connect(new AFUNIXSocketAddress(socketFile)); > InputStream is=sock.getInputStream(); > BufferedOutputStream bos=new BufferedOutputStream( > sock.getOutputStream()); > String cmd="help \n\0";//Don't forget \n\0 otherwise liquidsoap > won't consider the command > bos.write(cmd.getBytes()); > bos.flush(); > DataInputStream in = new DataInputStream(is); > BufferedReader br = new BufferedReader(new > InputStreamReader(in)); > String strLine; > //Read File Line By Line > while ((strLine = br.readLine()) != null) { > System.out.println (strLine); > } > bos.close(); > is.close(); > sock.close(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > } > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > _______________________________________________ > Savonet-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/savonet-users > > ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ Savonet-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/savonet-users
