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: Richard Carlson <>
  • To: Daniel Romero <>
  • Cc:
  • Subject: Re: recv_msg problem
  • Date: Thu, 10 Sep 2009 15:14:56 -0500

Hi Daniel;

Cool.  Please note that NDT is an open source project and we can always put contributed code in the packages contrib directory.  Send me patches if you want to share your work with the NDT community.

Rich
 
On Sep 10, 2009, at 2:48 PM, Daniel Romero wrote:



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




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