I am trying to send a structure via tcp/ip,i dont know if i am doing it good,it prints a strange chaarcter in my screen.Here is my code that i am using to send and recv:
void Send(const void* buffer, int size)
{
int n;
if((n = ::send(desc, (char*)&buffer, size, 0)) < 0)
{
cout << "Error in Send()" << endl;
}
cout << n;
}
void Recv(void* buffer, int size) {
size_t n = 0;
n = ::recv(remoteSocket, (char*)&buffer, size, 0);
}
struct packet {
unsigned char version;
unsigned char nMethods;
unsigned char methods[255];
};
packet p;
p.version = SOCKS_VER;
p.nMethods = 4;
p.methods[0] = METHOD_AUTH_NO;
p.methods[1] = METHOD_AUTH;
p.methods[2] = METHOD_GSSAPI;
p.methods[3] = METHOD_NO_ACCEPT;
c.Send((void*)&p, sizeof(p));
PS: it send all 257 bytes,and receives all 257 bytes.