May 29, 2024, 06:28:25 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


irc client

Started by chris, February 20, 2009, 04:34:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

chris

i am trying to use the client lib to make an irc client the problem is its not working and i can't work out why its not. it seams to send the frsit mesge okay however it dosen't seam to wait for a responce for any comands sent affterwards any help would be of use OPENCONSOLE
DEF ip : STRING
DEF Confrim, DataSend, comand, prefex, ending, cont: STRING
istring buffer[10000]
DEF log$ : File
DEF  Status :INT
INPUT "conect? [y/n]", Confrim
IF Confrim = "n"
goto die
ENDIF
ncsStatus = NCSInit(1,0)
if ncsStatus<0
       print "Error initializing Client Server library"
       print NCSGetErrorText()
endif
ncsStatus = NCSConnectToServer("irc.chatuniverse.net",6667)
if ncsStatus < 0
       print "Error connecting to server"
       print NCSGetErrorText()
   GOTO die
else
       datasocket = ncsStatus
       print "Connected to server ",datasocket
   ip = NCSGetLocalIP(datasocket)
   print ip
endif
DataSend = "USER IceChat7 \"localhost\" \"irc.chatuniverse.net\" :The Chat cool people use"
Status = SendData(DataSend,ip,datasocket)
Error(Status)
Status = NULL
DataSend = "JOIN ChrisTestRoom"
Status = SendData(DataSend,ip,datasocket)
Error(Status)
PRINT "End of Program"
DO : UNTIL INKEY$ <> ""
IF NCSCloseSocket(datasocket) < 0
PRINT NCSGETERRORTEXT()
ENDIF
PRINT "any key to close"
DO : UNTIL INKEY$ <> ""
NCSFREE()
label die
CLOSECONSOLE
SUB SendData(comand : String, ip :string, dataSocket : int), INT
DEf DataSend as STRING
istring buffer[10000]
ncsStatus = NULL
DataSend = comand+CHR$(13)+CHR$(10)
IF NCSSENDDATA (dataSocket,DataSend,Len(DataSend)+1)
PRINT " data sent"
ELSE
PRINT "error"
print NCSGETERRORTEXT()
GOTO die
ENDIF
DO : UNTIL NCSWaitForData(dataSocket,10000) = TRUE
ncsStatus = NCSReadData(dataSocket,buffer,19999,2000)
     if ncsStatus > 0
         buffer[ncsStatus]=0
         print buffer,
RETURN 1
     elseif ncsStatus < 0
         PRINT "ERROR :"
print NCSGETERRORTEXT()
RETURN 0
endif
ENDSUB
SUB Error(Status : INT)
DEF cont : string
cont = ""
IF Status = 0
INPUT "error, continue? [y/n] ",cont
If cont = "n"
goto die
ENDIF
ENDIF
ENDSUB

thanks in advace for your help
P.S. sorry if this is the wrong place, this just seemed like the best place for it