Hi all,
I'm going to create an interaction between IRC <-> RS client using SRL and the socket module. I'm pretty familiar with sockets and have been using them in many languages. I now just need some details to implement them on the correct way using the Socket modole which is in the SRL package. So far, this is my code (excuse me for the hard coding of the sockets, it's fine for now);
Now I need to both interact with the IRC server and with the client of RS. Since there is no multithreading/asynchronous approach (yet?) I have to think about something else. For people not knowing the IRC protocol; the only real requirement of IRC is to react on PING send by the server. Currently I don't really have an idea about how to do this.. I was thinking of about looping every 200ms (just using a repait + wait(x)) and then using RecvSocket (which doesn't block right? no data -> empty string?) to check if there is data. If there is no I don't need to bother with it. Is this a good strategy? Or do you people have any other ideas how to approach this problem? Last but not least, are there any good string handling modules for Pascal/LAPE? (Tried google, no results) I'm looking for functions such as Split(delimeter).Code:program new; {$i SRL-OSR/srl.simba} function ConnectIRC(server, port : String, timeout : Integer) : Integer var ssid : Integer; begin //Create socket, connect to socket and set a specified timeout ssid := CreateSocket; ConnectSocket(ssid, server, port); SetSocketTimeout(ssid, timeout); //Wait for the connection and after that send first IDENT respnse Wait(5000); SendSocket(ssid, 'USER doornder 8 * :doornder' + (#13#10)); SendSocket(ssid, 'USERHOST doornder 8 * :doornder' + (#13#10)); SendSocket(ssid, 'NICK doornder' + (#13#10)); Wait(1000); WriteLn(RecvSocket(ssid)); Result := ssid; end procedure JoinChan(ssid: Integer, channel : String) begin SendSocket(ssid, 'JOIN '+ channel + (#13#10)); end procedure Loop(ssid : Integer) var active : Boolean; data : String; begin active := True; repeat //All handling for PING, PONG, incoming message for IRC here.. Wait(200); //Try to read data and check if empty??.. data := RecvSocket(ssid); until active = false; end var socketid = Integer; begin socketid := ConnectIRC('irc.freenode.net', '6667'); JoinChan('#simbabot'); Loop(socketid); end.
Thank you in advance!
wptmdoorn


Reply With Quote








