java - How to create a custom binary protocol server? -
please advise should best solution create custom binary protocol server. server should accept communication multiple devices via binary protocol on tcp/ip.
is there existing server/framework solution available? i.e. node.js suitable solve problem? preferred solution java oriented.
thanks in advance!
update: binary protocol required reduce amount of communication data. text format protocol verbose. protocol device specified.
i implemented such thing time ago. used 2 standard java api's that:
- java.net package: java.net.serversocket , java.net.socket should able address of needs.
- java.concurrency package: each new connection socket accepted serversocket instance may want move processing of connection socket thread , start listening next connection using blocking serversocket.accept() method again - kind of producer-consumer pattern implementation. can done publishing socket new connection queue, used feed thread pool , each thread in thread pool takes care of actual connection handling.
note: when not sure kind of conversational pattern going happen between client , server (which 1 if them expected send data first on tcp/ip instance) make sense read data socket , write data same socket in separate threads too.
Comments
Post a Comment