[REBOL] TCP server/client
From: maillist::peter::home::se at: 10-Oct-2005 21:48
Hello!
I am trying to learn the basics of TCP server/client programming
and thought that the IRC protocol should be a good protocol to
use for that purpose since it is line based ASCII commands.
As long as the message is received on the irc port everything
seems OK, but it seems that new connections are opened on one of
several possible port numbers. How do I handle this? Do I need
to listen to all these ports? I feel a little bit confused...
irc: open/lines tcp://irc.amiganet.org:6667
while [ wait irc ] [
response: copy first irc
print [ "R:" response ]
if ((find response "Checking Ident") <> none) [
text: {NICK Wonko USER Wonko debian irc.amiganet.org :Peter Carlsson}
print [ "S:" text ]
insert irc text
]
if ((find response "Nickname is already in use") <> none) [
text: {NICK Anduril USER Anduril debian irc.amiganet.org :Peter Carlsson}
print [ "S:" text ]
insert irc text
]
if ((find response "PING") <> none) [
text: copy response
replace text "PING" "PONG"
print [ "S:" text ]
insert irc text
]
]
Best regards,
Peter Carlsson