Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Sending and recieving 'int' data (Sockets)

$
0
0
Hi guys!
I've just cleared up making my server and client.
I can tell they work because I made it do so:
If the server is open, and the client connects, it'll gladly allow them to play.
If the server is NOT open, and the client tries to connect, It will tell them the server is down.
(Just thought i'd get that out of the way before a "Are you sure it's connecting?" comment =D)

Alright so here's my problem...
I made sort of a test application for testing around with sockets and SDL together.
Everything is working PERFECTLY.
What I did was make the Client send their player position (player_x/player_y) to the server, In which the server 'cout' s the player position.

When I try to send the position, It'll tell me 'int' does not work in send(). Which is understandable,
But how would I do this?
I've been looking up how to convert int to char, and a this is one that pops up:
sprintf(char, "%d", int);
However, That doesn't work. It doesn't give me an error, but it just doesn't 'cout' the proper int value.

So what i'm basically trying to say is:
How do I convert int to char so that I can send it from the Client to the Server?

Viewing all articles
Browse latest Browse all 51036

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>