Hi all,
I have two application:
msgserver.c
[code]#include <sys/neutrino.h>
#include <stdio.h>
#include <inttypes.h>
#include <errno.h>
void main(){
int receivedId;
int channelId;
char message[512];
channelId = ChannelCreate(0);
printf("Channelcreated. Id: %d\n", channelId);
while(1){
receivedId = MsgReceive( channelId, message, sizeof(message), NULL );
printf("Server: Message id: %d, message text: %s\n", receivedId, message);
sprintf(message, "This is a reply to message with id(%d)\n", receivedId);
MsgReply( receivedId, EOK, message, sizeof(message) );
}
}[/code]
and msgclient.c
[code]#include <sys/neutrino.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( int argc, char** argv){
char *smsg = "msg";
char rmsg[512];
int connectionId;
connectionId = ConnectAttach(0, atoi(argv[1]), 1, 0, 0 );
if( connectionId == -1){
fprintf(stderr, "Connection attach error!\n");
return EXIT_FAILURE;
}
if( MsgSend(connectionId, smsg, strlen(smsg) + 1,
rmsg, sizeof(rmsg) ) == -1 )
{
fprintf(stderr, "MsgSend error!\n");
return EXIT_FAILURE;
}
if( strlen(rmsg) >0){
printf("Received message: %s\n", rmsg);
}
}[/code]
when I run msgclient, msgserver prints following:
Server: Message Id: 2, message text: msg
Server: Message Id: 2, message text:
and msgclient gets reply as expected.
Client sends the message only once, So the quiestion is: why the second “empty” message is received?
Actually this message is not emty, it contains 3 symbols: SYN, SOH and EOT (0x16, 0x1 and 0x4)
Is it correct behaviour? I need server to receive only one message that I send from client.