Chat client/server
Chat client/server
Hi, i am pretty new at programming, and to start me off, i would like to create a small chat server/client, but i dont know how to go about it. Can someone please show me an example of a server recieving data from a client, and then sending that data again to all clients? This would be of great help to me, as i need a kickstart off.
Why did the chicken cross the road?
Because he was on the same side as you!
Because he was on the same side as you!
-
- PureBasic Expert
- Posts: 2812
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
Check out the PB examples directory 
Also go to www.purearea.net for lot's and lot's of example code
@ Andre : When is the next update...???

Also go to www.purearea.net for lot's and lot's of example code

@ Andre : When is the next update...???
- Andre
- PureBasic Team
- Posts: 2137
- Joined: Fri Apr 25, 2003 6:14 pm
- Location: Germany (Saxony, Deutscheinsiedel)
- Contact:
Can't say exactly, I haven't much spare time at the moment.Num3 wrote:@ Andre : When is the next update...???
I will add all new userlibs/dll's this week, and after that the next code-archive should be done. But if it should become a well-done release, than all the codes must be checked with PB3.90.... :roll:
good luck with that!!!Andre wrote:... than all the codes must be checked with PB3.90.... :roll:

but seriously.. I'm extremely happy that someone will do it.. it's *alot* og code...
AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
examples..
I cant seem to find any examples on a chat client/server, and, all the advanced sources, and some of the sources in the purebaisc example directory doesnt work :-\, error messages come up like "AllocateMEmory function error: too many parameters", and "Function not found".
Why did the chicken cross the road?
Because he was on the same side as you!
Because he was on the same side as you!
damn your right
there was one on http://www.reelmediaproductions.com/pb
but Paul have pulled the plug on the resource site
Well for now you can mess with this German one, i found on the German Forum:
Start the server and then as many clients as you like: >>Click Here<<
Best regards
Henrik
there was one on http://www.reelmediaproductions.com/pb
but Paul have pulled the plug on the resource site

Well for now you can mess with this German one, i found on the German Forum:
Start the server and then as many clients as you like: >>Click Here<<
Best regards
Henrik
IRC
ok then, for now ill just create a client to connect to an IRC server. HOwever, i believe you need to send something to the IRC server before you can join, your name, etc..., however i dont know what order/where/how you send this to the server. If someone could give me what you need to send, that would be a great help.
Why did the chicken cross the road?
Because he was on the same side as you!
Because he was on the same side as you!
Found this somewhere here in the forum:
http://www3.sympatico.ca/airblazer/IrcEngine.zip
This one is a good irc engine written in PB.
Big source though..
Timo
http://www3.sympatico.ca/airblazer/IrcEngine.zip
This one is a good irc engine written in PB.
Big source though..
Timo
quidquid Latine dictum sit altum videtur
thank you. I did not use that german one because i cant read german, plus i now have tha basic grasps. i have one last, noobish question. How would i append a string infront of another string? e.g. put "name: " in front of "hello" to make "name: hello"
Edit: and how do you send the message to all of the clients connected? i dont understand the german server example system of doing it..
Edit: and how do you send the message to all of the clients connected? i dont understand the german server example system of doing it..
Why did the chicken cross the road?
Because he was on the same side as you!
Because he was on the same side as you!
a.s = "world"
b.s = "hello "+a.s
b.s = "hello "+a.s
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
The German use a linked listdwfait wrote: Edit: and how do you send the message to all of the clients connected? i dont understand the german server example system of doing it..
Code: Select all
NewList Client.l()
it walkes through every single one on the list and sends the Text
Linkedlist is very powerfull for this kind of stuff
Read in the help about Linked list
** Press F1 **
Try this from the help and ad some Friends
it's the same way the German server uses:
Code: Select all
NewList Friends.s()
AddElement(Friends())
Friends() = "Arnaud"
AddElement(Friends())
Friends() = "Seb"
AddElement(Friends())
Friends() = "dwfait"
ResetList(Friends())
While NextElement(Friends())
Debug Friends() ; Display all the list elements
Wend
Code: Select all
;Send to All
Procedure SendToAllOthers(ID, Text.s)
ResetList(Client()) ; Resetes to the start of the list
While NextElement(Client()) ; Walkes through all Clients of the list
;* The ID is the client who send the text to the server in the first place
If Client() <> ID
SendNetworkString(Client(), Text.s)
EndIf
Wend
EndProcedure
Best Regards
Henrik