Hello, I would like send a message like this with my client (so my card rabbit) :
char *hello = "Hello from client";
char buffer[1024] = {0};
//there are the arguments for socket too
if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
{
printf("
Connection Failed
");
return -1;
}
send(sock , hello , strlen(hello) , 0 );
printf("Hello message sent
");
valread = read( sock , buffer, 1024);
printf("%s
",buffer );
return 0;
}
But I must to convert it with dynamic C, looking at the doc i didn’t see this function (execpted in udp but i need tcp)
I found this to start :
if(sock_tbleft(&my_socket,size)) {
sock_write(&my_socket,buffer,size);
i tried to convert it little like it : (but it doesn’t really work ^^,)
if(sock_tbleft(&my_socket,size)) {
sock_write(&my_socket,buffer,size);}
sock_write(&my_sock , hello , strlen(hello) , 0 );
printf("Hello message sent
");
valread = read( sock , buffer, 1024);
printf("%s
",buffer );
return 0;
}
So I suppose send = sock_write but some people advice to see ModBus_slave but i don’t really understand why.
I must create a communication between my server and my card in using TCP to receive a message if my led = 1 then my server write : “your led blinks” ofc to start I have created my socket and establish connection but I block for the transmission part of the message.
If you have example or idea tell me please.