Hello I wrote a code in cpp which connects to a server using SMB protocol. Here I'm using smbclient command to connect to client but the big concern is smbclient is not returning proper error code(because smb is modified here) when sever is poweroff or restarted. So to handle it I came up with an idea using the ping command before making connection to server if ping fails I return Unreachable else will submit smbclient command to connect it.
Below is my approach please help me to find proper solution
#define no_of_packet 2
#define wait_time 1
int main {
int status = ping(no_of_packet,wait_time); // This is my ping API
if(!status) {
std::cout<<"Unreachable" <<std::endl;
return error::unreachable;
}
std::string command= server+ "-u" + user + pass
system(command);
return 0;
}