Socket programming using the send send structure
Structure before body with four synchronization characters, synchronous character as hexadecimal number 16 SYN (ASCII), ah, how to understand this sentence)
struct TabFLogin { BYTE Reserved; BYTE LenTab; BYTE TSCLinkCode; BYTE RetSIDE; BYTE TSC_Id; }; Struct TabFLogin TabFLogin_1; TabFLogin_1. LenTab=5; TabFLogin_1. TSCLinkCode=103; TabFLogin_1. RetSIDE=1; TabFLogin_1. TSC_Id=3; Char send_buf [1024]. Memset (send_buf, 0102, 4); Memcpy (send_buf, & amp; TabFLogin_1, sizeof (TabFLogin_1)); ClientSocket - & gt; The Socket - & gt; SendBuf (send_buf, 0); CodePudding user response:
Send_buf before four bytes 0 x16, send_buf + 4 to structure content,
CodePudding user response:
reference 1st floor u010165006 response: send_buf before four bytes 0 x16, send_buf + 4 to structure content, How to write, thank you CodePudding user response:
refer to the second floor Leighf response: Quote: refer to 1st floor u010165006 response: Send_buf before four bytes 0 x16, send_buf + 4 to structure content, How to write, thank you for(int i=0; i<4. I++) * ((char *) (send_buf + I))=0 x16; Memcpy (send_buf + 4, & amp; TabFLogin_1, sizeof (TabFLogin_1)); Handwriting verification, you give it a try, CodePudding user response:
for(int i=0; i<4. I++) Send_buf [I]=0 x16 (char); Ok, send_buf array is the char type, CodePudding user response:
7 integer input to the minimum and maximum number first exchange with the last number, then output exchange after seven digits CodePudding user response:
The original poster can try the following written as, with a big structure to include small structure struct TabFLogin { BYTE Reserved; BYTE LenTab; BYTE TSCLinkCode; BYTE RetSIDE; BYTE TSC_Id; }; Struct SendBufData { BYTE syn [4]. Struct TabFLogin data; }; Struct SendBufData TabFLogin_1; Memset (TabFLogin_1 syn, 0 x16, 4);//fill the SYN data TabFLogin_1. Data. LenTab=5; TabFLogin_1. Data. TSCLinkCode=103; TabFLogin_1. Data. RetSIDE=1; TabFLogin_1. Data. TSC_Id=3; Char send_buf [1024]. Memset (send_buf, 0102, 4); Memcpy (send_buf, & amp; TabFLogin_1, sizeof (TabFLogin_1)); ClientSocket - & gt; The Socket - & gt; SendBuf (send_buf, 0);