Chat client/server

Just starting out? Need help? Post your questions and find answers here.
dwfait
User
User
Posts: 15
Joined: Thu Mar 11, 2004 7:27 pm

Chat client/server

Post by dwfait »

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!
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Check out the PB examples directory ;)

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


@ Andre : When is the next update...???
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post by Andre »

Num3 wrote:@ Andre : When is the next update...???
Can't say exactly, I haven't much spare time at the moment.

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:
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

Andre wrote:... than all the codes must be checked with PB3.90.... :roll:
good luck with that!!! :twisted:

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
dwfait
User
User
Posts: 15
Joined: Thu Mar 11, 2004 7:27 pm

examples..

Post by dwfait »

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!
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

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
dwfait
User
User
Posts: 15
Joined: Thu Mar 11, 2004 7:27 pm

IRC

Post by dwfait »

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!
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Whats wrong with the one i pointed you to ?

Mess with that one first and get the basis.
you have to read up on how IRC, works and stuff, chat like the one i pointed is more simple.

Anyway it's your call.

Best Regards
Henrik
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

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
quidquid Latine dictum sit altum videtur
dwfait
User
User
Posts: 15
Joined: Thu Mar 11, 2004 7:27 pm

Post by dwfait »

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..
Why did the chicken cross the road?
Because he was on the same side as you!
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

a.s = "world"
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... )
dwfait
User
User
Posts: 15
Joined: Thu Mar 11, 2004 7:27 pm

Post by dwfait »

ah, that simple? in my previous language you couldnt do that with atrings :-\
Why did the chicken cross the road?
Because he was on the same side as you!
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

dwfait 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..
The German use a linked list

Code: Select all

NewList Client.l() 
When it sends "SendNetworkString()"
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 
The German Server procedure look like this:

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 
And btw of course you could ad strings together in blits, but but never mind.

Best Regards
Henrik
Post Reply