Created
June 23, 2013 22:03
-
-
Save qerub/5846713 to your computer and use it in GitHub Desktop.
Thrift + Unix domain socket server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.IOException; | |
import org.apache.thrift.protocol.TBinaryProtocol; | |
import org.apache.thrift.protocol.TProtocol; | |
import org.apache.thrift.transport.TFastFramedTransport; | |
import org.apache.thrift.transport.TIOStreamTransport; | |
import org.apache.thrift.transport.TTransport; | |
import org.newsclub.net.unix.AFUNIXServerSocket; | |
import org.newsclub.net.unix.AFUNIXSocket; | |
import org.newsclub.net.unix.AFUNIXSocketAddress; | |
public class ThriftUnixDomainSocketServer { | |
public static void main(String[] args) throws IOException { | |
File socketFile = new File("thrift.sock"); | |
if (socketFile.exists()) | |
socketFile.delete(); | |
AFUNIXServerSocket serverSocket = AFUNIXServerSocket.newInstance(); | |
serverSocket.bind(new AFUNIXSocketAddress(socketFile)); | |
AFUNIXSocket socket = (AFUNIXSocket) serverSocket.accept(); | |
TTransport ttransport = new TFastFramedTransport(new TIOStreamTransport(socket.getInputStream(), socket.getOutputStream())); | |
TProtocol tprotocol = new TBinaryProtocol(ttransport); | |
// tprotocol is ready to use! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
If it's possible can you provide the complete example.
I am new to java and need to complete this task ASAP.
Thanks
Ramesh