mIRC Homepage
Posted By: anticreeps Socket help - 11/08/05 12:22 AM
Hey im wondering if someone can give me a quick help on sockets because i read the tutorials, and help files on the mirc client but it just wont click in... what i want to do is connect to freechess.org on port 5000 and have the text show up in a seperate window and being able to send data with the socket can someone just help out with that i would really appreciate it thanks smile
Posted By: stefys99 Re: Socket help - 11/08/05 11:28 PM
Try this.. use /freechess
Code:
alias freechess {
    ;;configuration goes here;;
    set %freechess.window @freechess
    set %freechess.server freechess.org
    set %freechess.port 5000
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   if ($sock(freechess)) sockclose freechess
    sockopen freechess %freechess.server %freechess.port
    if (!$window(%freechess.window)) window -aek0 %freechess.window
}

on 1:sockopen:freechess:{
    if ($sockerr) { aline %freechess.window Error connecting to $+(%freechess.server,:,%freechess.port) | halt }
   aline %freechess.window Connected.
}

on 1:sockread:freechess:{
    var %data
    sockread %data
    aline %freechess.window %data
}
on 1:input:%freechess.window:if ($mid($1-,1,1) != /) && (!$ctrlenter) sockwrite -n freechess $1-
Posted By: anticreeps Re: Socket help - 12/08/05 07:31 PM
Thanks MAN appreciate it... this is actually helping me out in many ways and now with this example i understand more about sockets smile thanks again
Posted By: stefys99 Re: Socket help - 12/08/05 07:33 PM
No problem smile
Posted By: anticreeps Re: Socket help - 12/08/05 08:12 PM
actually one more question.. hehe for example if someone type !help how do i make it with socket to read that command and then with crlf say something with the socket then that should be it then i will understand most of it
Posted By: stefys99 Re: Socket help - 12/08/05 11:58 PM
Quote:
actually one more question.. hehe for example if someone type !help how do i make it with socket to read that command and then with crlf say something with the socket then that should be it then i will understand most of it

You have to put that in sockread event
Change the old sockread event with this:
Code:
on 1:sockread:freechess:{
    var %data
    sockread %data
    aline %freechess.window %data
    if (%data == !help) {
        sockwrite -n $sockname Here is your help:
        sockwrite -n $sockname blah blah blah
    }
}
© mIRC Discussion Forums