c++ - Sending null byte over a socket to a Windows Machine from Linux - Will it be same -
this based on earlier question asked . sending octet of 0 bits linux linux machine such on socket
const char null_data(0); send(newsockfd,&null_data,1,0); my question same when sending windows machine (64 bits) ? or have change code ?
the trick here use uint*_t data types, insofar feasible:
#include <cstdint> /* ... */ #if !defined(__win64) // *nix variant typedef int socket_fd_t; #else // winxx socket descriptor data type. typedef socket socket_fd_t; #endif void send_0_byte(socket_fd_t newsockfd) { uint8_t zero_byte(0); send(newsockfd, &zero_byte, 1, 0); } you want add error checking code, include correct platform socket header. uint8_t 8-bit quantity (octet) definition, meets requirement , avoids potential char size issues.
on receiver side, want recv uint8_t buffer.
Comments
Post a Comment