Advertisement

Yet another winsock error...

Started by April 10, 2002 02:18 PM
8 comments, last by BioSquirrel 22 years, 9 months ago
OK when I try to send an integer to the server, it gives me this error: error C2664: ''send'' : cannot convert parameter 2 from ''int'' to ''const char *'' This is the code I''m using to send: send(go,Player1.xpos,sizeof(Player1.xpos),0); ------------------ Stupid Morons- my current projects
quote:
Original post by BioSquirrel
send(go,Player1.xpos,sizeof(Player1.xpos),0);




try this

int xpos;
xpos = Player1.xpos;
send(go,&xpos,sizeof(Player1.xpos),0);
Advertisement
It''s still not working...

------------------
Stupid Morons- my current projects
send(go,(char *)&xpos,sizeof(Player1.xpos),0);
It wants a pointer and you''re supplying the actual variable.

I think you just need &(Player1.xpos) instead of Player1.xpos. You may have to cast it:

(char*)&(Player1.xpos)
Thanks Buster, it worked!

------------------
Stupid Morons- my current projects
Advertisement
I doubt that you would actually "recv" the right "xpos" value on the other side of the connection. Send() converts the integer value to only one byte when it is being send if you do it like that, and then you will end up with a whole other position. I think you have to make up another way to deal with integer values.

Please tell me if I'm wrong.

[edited by - TiStar on April 14, 2002 6:17:33 PM]
Have any suggestions?

------------------
Stupid Morons- my current projects
I''m so very sorry, I was wrong. That works just fine.
Sorry!
Bad.

Converting the pointer to a char pointer doesn''t truncate your data. Since he is passing in the size of the memory segment (size of an integer), 4 bytes will still be sent.

Dire Wolf
www.digitalfiends.com
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com

This topic is closed to new replies.

Advertisement