abhishek
abhishek

Reputation: 817

Sending string data over TCP in visual c++

I want to send some data in form of continuous strings from a visual c++ program to an android app via wifi. I'm trying to make a tcp server that sends the data continuously. What c++ library should I use for this which will be easy to use and won't require some library on the android side for decoding etc.? I have already coded the android client part that receives the strings (I used an existing server app to test it out). Here's the relevant part of the android code -

class ServerThread implements Runnable {
    @Override
    public void run() {
        Socket s = null;

        try {
            Log.d("TAG", "connecting to server");               
            s = new Socket("192.168.56.1", 1337);
            BufferedReader input = new BufferedReader(new InputStreamReader(s.getInputStream()));
            while(true){
                String line = input.readLine();}

Upvotes: 0

Views: 1910

Answers (2)

Austin J.
Austin J.

Reputation: 138

Boost asio is a great networking library for general purposes.

Take a look at this question

Best C/C++ Network Library - Already asked question

about good networking libraries.

Assuming you want to go with boost, this may help you

Android NDK: Including boost c++ library

Upvotes: 0

beardedN5rd
beardedN5rd

Reputation: 185

The library of choice for me is boost asio. http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio.html

The tutorials are suitable for what you have in mind.

Upvotes: 2

Related Questions