mIRC Home    About    Download    Register    News    Help

Print Thread
Socket help #127239 11/08/05 12:22 AM
Joined: Aug 2005
Posts: 21
A
anticreeps Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2005
Posts: 21
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

Re: Socket help #127240 11/08/05 11:28 PM
Joined: Aug 2005
Posts: 128
S
stefys99 Offline
Vogon poet
Offline
Vogon poet
S
Joined: Aug 2005
Posts: 128
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-

Re: Socket help #127241 12/08/05 07:31 PM
Joined: Aug 2005
Posts: 21
A
anticreeps Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2005
Posts: 21
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

Re: Socket help #127242 12/08/05 07:33 PM
Joined: Aug 2005
Posts: 128
S
stefys99 Offline
Vogon poet
Offline
Vogon poet
S
Joined: Aug 2005
Posts: 128
No problem smile

Re: Socket help #127243 12/08/05 08:12 PM
Joined: Aug 2005
Posts: 21
A
anticreeps Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2005
Posts: 21
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

Re: Socket help #127244 12/08/05 11:58 PM
Joined: Aug 2005
Posts: 128
S
stefys99 Offline
Vogon poet
Offline
Vogon poet
S
Joined: Aug 2005
Posts: 128
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
    }
}