Link to home
Start Free TrialLog in
Avatar of eddie_kho
eddie_kho

asked on

Create a Multiplayer Game Using Delphi TCP/IP Socket Object

How to send a broadcast data using Delphi TCP/IP Socket. Anybody can tell me or give me a reference on web, pls?
Avatar of inthe
inthe

hi,
look at the examples (chat etc ) of the internet component suite here:
http://www.rtfm.be/fpiette/indexuk.htm
particularly te examples using wsocket .
same for the winshoes comps:
http://www.pbe.com/Winshoes/
i have a chat program, using serversocket and clientsocket. If you need it you can send an email to cool17@geocities.com
For Server(Send):
ServerSocket1.Socket.Connections[index].SendText([TEXT as String])

For Client(Send):
ClientSocket1.Socket.SendText([Text as String]);

To get the sent string:
see the event onclientwrite or onwrite:
use the function socket.receivetext to get the sent string.
Avatar of eddie_kho

ASKER

i meant to send a broadcast message not a point to point message, sorry, u don't understand the question maybe... pls try again thanks...
May I suggest you use something done for games
like directX. Yes I know this is not easy to use. But they is a good and easy
component suite for delphi called delphiX.
You can get it here :
http://www.multimania.com/trident/informatique/delphix/delphix/delphix02-2000.zip

Believe me : you get the sources and it's really easy to use.
Why should you use that ? Because
DirectX is done for games. DelphiX does
all for you, they is a sample using directConnect.
And what more ? You can use tcp/ip but
also null modem, ipx workless for you.
The component is doing everything for
you. I can send you a small game using
directconnect working with for players
to show you.

Regards.

-John.
Ok, if you want to broadcast the message, just run the statement in the looping.
like:

For I := 0 To ServerSocket1.Socket.ActiveConnections -1 Do
Begin
   ServerSocket1.Socket.Connections[I].SendText('Something to broadcast');
End;

Please tell me again if this one cannot answer your question too.
Adjusted points from 50 to 200
As we know, TCP/IP is connection oriented protocol. Your answer can be implemented in one condition that all the computer on network connected to my program (as a server) in a computer. This not actually a answer i want to hear about, what i meant is i want to send a package to all the computer in my network without connection required. If i use IPX/SPX that does not a big matter, the problem is i want implemented the same method as i use on IPX/SPX to TCP/IP. OK, if that's couldn't be possible, could you please tell me another method i can use to make a multiplayer game on TCP/IP? thanks
What about my comment Eddie ?
Eddie,

There is a protocol which is called UDP which is a subset of the TCP/IP protocol. It is used by games like Quake3 to communicate between client and server. It is described as a connectionless protocol because it is a broadcast protocol.

You should try to find a socket component that allows UDP broadcasting.

Try the Crescent tools set.
jeurk>

i'm sorry, but i still can not download the file yet, it's never downloaded completely. would you please attached it to a mail and send to me? i will learning to use it as soon as i receive it. my address: eddie_kho@hotmail.com
thank you very much
I sent it.
ASKER CERTIFIED SOLUTION
Avatar of jeurk
jeurk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Broadcasting cannot be done, but you can EASILY implement client/server games.

Just have a single server, and clients connect to it.
In the OnClientRead event, the server enumerates through all connections and sends the data it received to all connected clients.

It's what I used to write a multi-user chat program, and it worked fine. Let me know if you want the source or something else is not clear.
what's going on eddie ?
jeurk>
really sorry jeurk, that recently i have not much time to explore your delphiX document, but i think i will receive it as the answer, thanks