Skip to Content.
Sympa Menu

ndt-users - Re: recv_msg problem

Subject: ndt-users list created

List archive

Re: recv_msg problem


Chronological Thread 
  • From: Daniel Romero <>
  • To: Richard Carlson <>
  • Cc:
  • Subject: Re: recv_msg problem
  • Date: Thu, 10 Sep 2009 15:48:35 -0400
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=h0HkxAjimQhG2yzfkgGqQ89jjqQ4LATQfn3rrzPPj+zV3YtIYBo7l8axzKSrpKyq50 N/qiu/cgKpi9M8kz5qqZH4HcQz+aZ3fWaMGPBeL4ZwnWO5Ywo19tdAGWRHxC3qaP0HAa xPTzPjdIdTpQn6Mym/9ZLYRVMI/Hkd3lufYJY=



The system is now working fine and supporting sha1 authentication.

I just called msgLen = sizeof(buff) before each recv_msg call.

Regards.




2009/9/10 Daniel Romero <romero.cl@gmail.com>
Hi Richard.

I know that those functions were designed for protocol messages, im working on some extensions to support sha1 authentication.

Aaron was right, msgLeng was not set to sizeof(dbuff), a previous call to recv_msg set it to 4, that was the problem.

Thanks a lot both of you.

Best regards.


2009/9/10 Richard Carlson <>

Hi Romero;

The NDT send_msg() and recv_msg() functions are not meant to be a generic communications protocol.  They were designed to allow the server and client to exchange status information about what was happening.  There is also a message type to allow the delivery of some data between the 2 nodes.  The specific message types are defined in the protocol.h file.  The send/recv functions are defined in the network.c file.

Looking at the recv_msg() function code you will see that it returns a value of 2 if the length (10) is greater than len (4).  The length value is the size of the data message and len is the size of the char array needed to hold this data.  Since you can't put 10 bytes into 4 slots, you get back an error message (2).  You will need to fix your code to sent in a properly sized array.

Rich


On Sep 9, 2009, at 8:24 PM, romero.cl@gmail.com wrote:

Hi.

Im doing some modifications on ndt 3.5.0, but i have a problem:

Client side:

memset(buff, 0, sizeof buff);
sprintf(buff, "%-s", "xxxxxccccc");
n = send_msg(ctlSocket, 100 , buff, strlen(buff));   (n = 0 after this, that's ok)

in client's log: >>> send_msg: type=100, len=10


Server side:

memset(dbuff, 0, sizeof dbuff);
n = recv_msg(ctlsockfd, &msgType, dbuff, &msgLen);
dbuff[msgLen] = 0;

in server log: recv_msg: length [10] > *len [4]

after this n=2 and dbuff is empty, i don't know why read_msg is returning 2


any ideas?



Regards.

Richard Carlson

1000 Oakbrook Dr
Ann Arbor, MI  48104

P: 734-352-7043
C: 630-251-4572






Archive powered by MHonArc 2.6.16.

Top of Page