Page 1 of 1
Chat client/server
Posted: Mon Apr 19, 2004 4:09 pm
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.
Posted: Mon Apr 19, 2004 7:57 pm
by Num3
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...???
Posted: Mon Apr 19, 2004 10:38 pm
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:
Posted: Tue Apr 20, 2004 8:55 am
by LarsG
Andre wrote:... than all the codes must be checked with PB3.90.... :roll:
good luck with that!!!
but seriously.. I'm extremely happy that someone will do it.. it's *alot* og code...
examples..
Posted: Wed Apr 21, 2004 1:10 pm
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".
Posted: Wed Apr 21, 2004 1:42 pm
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
IRC
Posted: Wed Apr 21, 2004 6:26 pm
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.
Posted: Wed Apr 21, 2004 7:20 pm
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
Posted: Wed Apr 21, 2004 7:28 pm
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
Posted: Wed Apr 21, 2004 7:45 pm
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..
Posted: Wed Apr 21, 2004 8:01 pm
by blueznl
a.s = "world"
b.s = "hello "+a.s
Posted: Wed Apr 21, 2004 8:06 pm
by dwfait
ah, that simple? in my previous language you couldnt do that with atrings :-\
Posted: Wed Apr 21, 2004 8:41 pm
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
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