Ardunio Mega 2560 Serial Communication Problem

I’m trying to send serial messages to arduino mega with c++ application by using boost asio. However no messages is sent. when we use same application with nano or uno it works perfectly. by using serial port in the ide we can send data. I dont know what’s the difference between them to change my code.

I’m trying this;

#include <SoftwareSerial.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
while(Serial.available()){
Serial.write(Serial.read());
}
}

Cpp code ;

portt = std::make_sharedboost::asio::serial_port(io, “/dev/ttyUSB0”);

portt->set_option(boost::asio::serial_port_base::baud_rate(9600));

portt->set_option(boost::asio::serial_port::flow_control(
boost::asio::serial_port::flow_control::none));

portt->set_option(boost::asio::serial_port_base::parity(
boost::asio::serial_port_base::parity::type::none));

portt->set_option(boost::asio::serial_port_base::stop_bits(
boost::asio::serial_port_base::stop_bits::one));

portt->set_option(boost::asio::serial_port_base::character_size(8));

std::string message = “MY MESSAGE HERE &\n”;

using namespace std::chrono_literals;
std::this_thread::sleep_for(100ms);

for (int i = 0; i < 100000; ++i) {

boost::asio::write(*portt, boost::asio::buffer(message));

std::this_thread::sleep_for(100ms);
}

Are you sure you are connected to Rx0 and Tx0 ?

Run the example coms program on the Arduino IDE to check your board is ok

I do not get any response when I connect on the programming cable. Just tx light is flashing. If connect to tx0 and rx0 using FTDI, i can not any response but when i press the reset on arduino, printing data once. I tried with two different arduino mega.