mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2015
Posts: 243
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Hi! Some days ago i had an idea of making a script that would act like a small server in which the "users" using an other simple script to act as a client would connect, sent me their OS name and then get disconnected by me. So.. following this tutorial http://www.mirc.org/mishbox/tutorials/sockets.htm
i wrote this script for server side
Code:
on *:socklisten:HumStats: {
  var %sockaccept $+(Hum,$rand(1,100))
  sockaccept %sockaccept
  sockwrite -n %sockaccept Connection Accepted.
}

on *:sockread:Hum*: {
  if ($sockerr) { sockclose $sockname | echo -at Error Occured Closed Connection }
  var %hum
  sockread %hum
  if (*OS* iswm %hum) {
write HumStats.txt $gettok(%hum,2,32)
    sockwrite -n $sockname Thanks for contributing! Bye!
    .timer 1 2 sockclose $sockname
  }
}


And this for client side
Code:
on *:SOCKOPEN:HumStatsClient: {
  window @HumStats 
  aline @HumStats Connecting To HumStats Server 
}

on *:sockread:HumStatsClient: {
  if ($sockerr) { sockclose $sockname | echo -at Error Occured Canceled Connection }
  var %HumStats
  sockread %HumStats
  if (*Accept* iswm %HumStats) {
sockwrite -n |OS| <bla bla>
.timer 1 5 sockclose $sockname
}
}

on *:sockclose:HumStatsClient: {
  aline @HumStats Connection Closed By HumStats! 
}

But it doesn't trigger..
I tried to do port forwarding for the port 90 because i did /socklist Hum 90 and then i disabled my firewall but no luck again..
What am i doing wrong?

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Connect to yourself (127.0.0.1) to eliminate the possibility of firewall issues.

Joined: Feb 2015
Posts: 243
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
It opens the socket and then the sockclose event triggers right away

Joined: Feb 2015
Posts: 243
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
nvm i figured it out..! smile


Link Copied to Clipboard