1 Replies - 214 Views - Last Post: 09 January 2013 - 04:49 PM Rate Topic: -----

#1 Blaze13  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 84
  • Joined: 11-November 12

Sending and recieving 'int' data (Sockets)

Posted 09 January 2013 - 04:42 PM

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?

Is This A Good Question/Topic? 0
  • +

Replies To: Sending and recieving 'int' data (Sockets)

#2 Blaze13  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 84
  • Joined: 11-November 12

Re: Sending and recieving 'int' data (Sockets)

Posted 09 January 2013 - 04:49 PM

Nevermind =P
Got it!
Didn't realize itoa was a function.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1