On Thu, Jul 31, 2008 at 11:58 PM, Ankit Shah <[EMAIL PROTECTED]> wrote:
> Here's the Client side code:
>
>   int main (int argc, char *argv[]) {
>   int sd, rc, i, len, done;
>   struct sockaddr_in localAddr, servAddr;
>   struct hostent *h;
>   char mystr[] = "TS1\tTS2\tTS3\tTS4\tTS5\tTS6\tTS7\tTS8\r\n";
>   struct packet{
>       uint32_t dataSize;
>       uint16_t dataId;
>       uint8_t data[50];
>   } mypacket;
>   char *cptr;
>   void *vptr;
>   cptr = mypacket.data;
>   vptr = &mypacket;
>   //memset(&mypacket,0x0,sizeof(mypacket));
>   memset(vptr,0x0,sizeof(mypacket));
>   //sprintf((char *) &mypacket.data, "%s", mystr);
>   sprintf(cptr, "%s", mystr);

If your data contains NULs, this sprintf() will fail/not work as you
want it. You need memcpy() instead.

>
>   mypacket.dataSize = strlen(mystr) + 2;

And this strlen won't work either.



-- 
PJH

'Two Dead in Baghdad' not 'product-friendly' - Kent Ertugrul, chief
executive of Phorm.

http://shabbleland.myminicity.com

Reply via email to