PDA

View Full Version : Socket Help



cas.felippe
01-08-2010, 07:59 PM
Hello my name is Luccas and i'm new here, Well I make a pong game and i'm planning to put the game online to me and my friend play. and in the future and with a little time of job create a more complex thing like rooms and something like that.
Anyone can help me this is my code i'm using:

Movimentation:
If isup in Form1.DXInput1.States then
Form1.ClientSocket1.Socket.SendText('up');
Server
If ServerSocket1.Socket.ReceiveText = 'up' then
ServerSocket1.Socket.Connections[0].SendText('upok');
Client
If ClientSocket1.Socket.ReceiveText = 'upok' then
Sprt.Y:= Sprt.Y+10;
I'm Having problem in this code i dont Know what is going wrong someone could help me

User137
03-08-2010, 07:15 AM
Your logic in the code seems ok, but you leave some questions open:
1) What network component are you using? DelphiX network component is very outdated.

2) "ServerSocket1.Socket.ReceiveText"
- Is this a function or a saved variable after receiving data?
- When are you using this (is it somesort of onData event)? Is this the correct way to use this by possible example projects?
- Do you use it more than once? If so, are you sure the ReveiveText remains the same. Maybe it is meant to be read to a variable first.
- Is the connection ok in both ways?