First Socket

By rikkeh on Jan 20, 2009

This was my First socket I made for my new site I purchased...

It's pretty easy, but I'm new to sockets, so here.

Edit: If any one can provide some Socket Tutorials that would be great :) and maybe give me some tips, much appreciated

alias -l htmlfree {

  ; It's local because it won't be used by the command line, only this file.

  ; Local aliases avoid conflicting names.
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}
on *:text:!forums:#:{
  /sockopen f2 thecodebook.org 80
  set %nick $nick
}
on *:sockopen:f2:{ 
  sockwrite -n $sockname GET /index.php HTTP/1.1 
  sockwrite -n $sockname Host: thecodebook.org $+ $crlf $+ $crlf
}
on *:sockread:f2:{
  if ($sockerr) {
    echo -a Error.
    halt
    sockclose $sockname
  }
  else {
    set %h
    sockread %h
    if (*users online* iswm $remove(%h,$chr(09))) {
      echo -t $regsub(%h,/<[^>]*>/g,,%h)
      notice %nick Their are a total of $gettok(%h,5,32) Users on HTttp://TheCodeBook.org $gettok(%h,9,32) Registered, $gettok(%h,11,32) Hidden, $gettok(%h,14,32) Guests.
      sockclose $sockname
    }
  }
}

Comments

Sign in to comment.
WannaKnow   -  Jan 23, 2009

I know but he has now:
he first halt it and the he close it that won't work

 Respond  
TheImrac   -  Jan 23, 2009

Wanna know, you should have the sockclose before the halt or else it wont execute. Also if I remember correctly, if there is an error, it will close the socket automatically.

 Respond  
WannaKnow   -  Jan 23, 2009

if ($sockerr) {
echo -a Error.
halt
sockclose $sockname
}

A error: It stop the script before it close it change the halt and the sockclose

 Respond  
Firstmate   -  Jan 20, 2009

This is just a small thing, but instead of using:

 set %h

It might be better to set a local variable:

var %h
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.