简体   繁体   中英

Java : How to achieve socket programming functionality with 3rd party API

I am working on a Existing Java Application, which is using Java Socket Programming for connecting to servers. Now my task is to replace this Socket Programming with a Third Party API.

To get the Data from the server with Socket Programming we can simply use:

InputStream socketInput = socket.getInputStream(); 

The above line will take care of getting the Data from the servers.

But how can we implement this behavior without using any Socket Programming?

Any ideas as how to implement this?

You didn't say what the third party toolkit was or what approach or protocol it was using. You can't avoid using sockets on some level when doing network programming, but you can use Java's higher level network APIs like HTTPUrlConnection to do HTTP operations for sending and receiving data.

If the third party API is also using stream abstraction it is simple. You just have to get input/output streams from other source.

If this API uses higher level abstraction (eg works directly with objects of your data model) you need to replace that layer in your code.

Please try to ask more specific question and you will get more specific answer.

If you still want use your own protocol but without using java.net directly you could use event-driven frameworks such as :

But if your considering sending your data over other protocols check this question Is there a good Java networking library?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM