CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    Socket question, can someone please help me ????

    Hi,
    If variable 'b' is a type of struct, say

    struct data {
    char packet[32];
    int alert;
    };
    ....
    data *b;
    what function from the winsock library can I use to send b to a remote client or server ??? CAN SOMEONE PLEASE HELP ME ??


  2. #2
    Guest

    Re: Socket question, can someone please help me ????

    1) memcpy that struct into a char buffer:
    char *buf = (char *)malloc(sizeof(data));
    memcpy(buf, &b, sizeof(data);
    send(socket, buf, sizeof(data), 0);

    or
    2) typecast to char *
    send(socket, (char *)&b, sizeof(data), 0);


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured