54 std::string tokenizer(
":");
55 size_t p_tokenizer = pathToDevice.find(tokenizer);
57 if (p_tokenizer == std::string::npos) {
59 server_host =
"localhost";
60 portno = atoi(pathToDevice.c_str());
64 server_host = pathToDevice.substr(0, p_tokenizer);
65 portno = atoi((pathToDevice.substr(p_tokenizer + 1)).c_str());
76 sockfd = socket(AF_INET, SOCK_STREAM, 0);
78 perror(
"MSOCKET::ERROR::OPEN_SOCKET");
83 perror(
"MSOCKET::ERROR::NO_SUCH_HOST");
88 bcopy((
char *)
server->h_addr,
95 perror(
"MSOCKET::OPEN_CONNECTION::CONNECT_ERROR");
100 printf(
"ERROR; return code from pthread_create() is %d\n",
rc);
118 memcpy(
msg_tx, str.c_str(), str.size());
119 int msg_ssz = str.size();
123 s.assign(
msg_tx, msg_ssz);
155 perror(
"SOCKET::READ::ERROR_READ_FROM_SOCKET");
164 std::cout <<
"MSOCKET::READ::ERROR::BUFFER_FULL ---> drop the oldest "
void * read_process_msocket(void *pMsocket_me_)
Function to read from the modem via a TCP/IP connection (it must be called as a pure C function).
void * read_process_msocket(void *)
Function to read from the modem via a TCP/IP connection (it must be called as a pure C function).
Header of the class derived from UWMconnector to handle the TCP/IP socket connection of a client betw...
#define _MODEM_OK
Variable to test the right opening of the modem's connection.
#define _MAX_MSG_LENGTH
Variable defining the maximum length of the messages \ exchanged between host and modem.
Header of the class needed by UWMPhy_modem to handle the different transmissions cases and correspond...
Class used to manage host/modem string exchange via TCP/IP connection (this class is a derived class ...
~Msocket()
Class destructor.
pthread_t thread_id
Id of a parallel thread.
char msg_tx[_MAX_MSG_LENGTH]
Message to be transmitted host to modem.
virtual int writeToModem(std::string)
Method for writing to the modem.
int rc
Indicator of the thread creation.
int getSocket()
Method to read the pointer to the socket where to write (it is needed by the reading function invoked...
struct sockaddr_in serv_addr
Structure to contain the Internet address to be used.
struct hostent * server
Structure to define the server host.
virtual int openConnection()
Method to open the connection with the modem.
int sockfd
Pointer to the socket.
virtual void closeConnection()
Method to close the connection with the modem.
Msocket(UWMdriver *, std::string)
Class constructor.
std::string server_host
Name of the server host on the Internet to which we want to be connected as client.
void error(const char *)
Method report errors.
The class needed by UWMPhy_modem to manage string exchange with the modem.
uint getDriverQueueLength()
std::queue< msgModem > queueMsg
Queue used to buffer incoming strings from the modem.
The class needed by UWMPhy_modem to handle the different transmissions cases and corresponding protoc...
int msg_length
Length of the message (bytes).
std::string msg_rx
Message from the modem.