Nuffilein805 Posted October 24, 2005 Share Posted October 24, 2005 (edited) ok, here's what i made again it's just a little chatprog for up to 100 clients i took some parts of the help-file to make it fit to what i need well, it works, but the servers quite slow, so i suggest you to not write messages from here anyway here's the code: server: expandcollapse popup;chat with 100 clients ;made by Marten Zimmermann #include <guiconstants.au3> global $g_port = 34000 Global $g_IP = @IPADDRESS1 Global $MainSocket dim $ConnectedSocket[101] dim $recv[101] dim $user[101] dim $pw[101] for $i = 1 to 100 step 1 $ConnectedSocket[$i] = -1 Next tcpstartup() $MainSocket = TCPListen($g_IP, $g_port, 100 ) If $MainSocket = -1 Then Exit $RogueSocket = -1 $main = GUICreate ("Chat Server", 500, 200) $input = GUICtrlCreateInput ("", 10, 10, 280) $edit = GUICtrlCreateEdit ("", 10, 40, 280, 110, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL) $userlist = GUICtrlCreateEdit ("Server", 300, 10, 190, 180, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL + $ES_WANTRETURN) $send = GUICtrlCreateButton ("Send", 10, 160, 280, 20, $BS_DEFPUSHBUTTON) GUICtrlSetState ($input, $GUI_FOCUS) GUISetState() $users = "Server" & @CRLF $users1 = $users while 1 $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE Then for $i = 1 to 100 step 1 if $ConnectedSocket[$i] <> -1 Then tcpsend ($ConnectedSocket[$i], "~~bye") EndIf Next tcpshutdown() Exit EndIf if $msg = $send Then if GUICtrlRead ($input) <> "" Then for $i = 1 to 100 step 1 if $ConnectedSocket[$i] <> -1 Then tcpsend ($ConnectedSocket[$i], "Server: " & guictrlread ($input)) EndIf Next GUICtrlSetData ($edit, guictrlread($input) & @crlf & guictrlread ($edit)) GUICtrlSetData ($input, "") EndIf EndIf for $i = 1 to 100 step 1 if $ConnectedSocket[$i] <> -1 Then $recv[$i] = tcprecv($ConnectedSocket[$i], 512) $err = @error if $recv[$i] = "~~bye" Then $ConnectedSocket[$i] = -1 tcpclosesocket($ConnectedSocket[$i]) $test = $user[$i] & "|" $users = StringReplace ($users, $test, "") GUICtrlSetData ($userlist, $users) if StringReplace ($users1, "|", @crlf) <> $users Then for $j = 1 to 100 if $ConnectedSocket[$i] <> -1 Then tcpsend($ConnectedSocket[$i], "~~users:" & $users1) EndIf Next EndIf EndIf if StringInStr ($recv[$i], "~~us:") Then $user[$i] = stringtrimleft ($recv[$i], 5) $test = $user[$i] & @CRLF if not StringInStr ($users, $test) Then if iniread ("chat.ini", "Users", $user[$i], "") <> "" Then tcpsend ($ConnectedSocket[$i], "~~password") Else tcpsend ($ConnectedSocket[$i], "~~accepted") USERLIST() EndIf EndIf EndIf if StringInStr ($recv[$i], "~~pw:") Then $pw[$i] = StringTrimLeft ($recv[$i], 5) if iniread ("chat.ini", "Users", $user[$i], "") = $pw[$i] then tcpsend($ConnectedSocket[$i], "~~accepted") USERLIST() Else tcpsend ($ConnectedSocket[$i], "~~password") EndIf EndIf if $recv[$i] <> "" and $err = 0 and $recv[$i] <> "~~bye" and not StringInStr($recv[$i], "~~us:") and not StringInStr($recv[$i], "~~pw:") Then for $j = 1 to 100 step 1 if $ConnectedSocket[$j] <> -1 Then tcpsend($ConnectedSocket[$j], $user[$i] & ": " & $recv[$i]) EndIf Next GUICtrlSetData ($edit, $user[$i] & ": " & $recv[$i] & @crlf & guictrlread($edit)) EndIf Else $ConnectedSocket[$i] = tcpaccept($MainSocket) EndIf Next WEnd func USERLIST() for $i = 1 to 100 step 1 if $ConnectedSocket[$i] <> -1 Then $test = $user[$i] & @CRLF if not stringinstr ($users, $test) Then $users = $users & $user[$i] & @CRLF EndIf Elseif $ConnectedSocket[$i] = -1 Then ;$users = stringreplace ($users, $user[$i], "") EndIf Next $users1 = StringReplace ($users, @CRLF , "|") for $i = 1 to 100 step 1 if $ConnectedSocket[$i] <> -1 Then tcpsend ($ConnectedSocket[$i], "~~users:" & $users1) EndIf Next GUICtrlSetData ($userlist, $users) EndFunc and the client: expandcollapse popup;client for 100client-server ;made by Marten Zimmermann #include <guiconstants.au3> global $connect_port = 34000 $ip = InputBox ("IP-Adress", "Gimme the IP-Adress of the Server", @IPAddress1) tcpstartup() $socket = tcpconnect ($ip, $connect_port) if $socket = -1 then Exit EndIf Do Do $user = InputBox ("Connected", "Connection established please type in your desired Username") if @error = 1 Then $end = msgbox (4, "End client", "Sure you want to exit?") if $end = 6 Then Exit EndIf EndIf until StringLen ($user) > 3 and StringLen ($user) < 12 tcpsend ($socket, "~~us:" & $user) Do $recv = tcprecv ($socket, 512) if $recv = "~~password" Then $pw = InputBox ("Password required", "Please type in the password for " & $user, "", "*") tcpsend ($socket, "~~pw:" & $pw) EndIf until $recv = "~~accepted" or $recv = "~~rejected" or @error = 1 until $recv = "~~accepted" or $recv = "~~rejected" if $recv = "~~rejected" Then msgbox (0, "Failure", "Maximum number of users reached or Server currently not availible, please try again later") Exit EndIf $main = GUICreate ("Chat Client - Connection established", 500, 200) $input = GUICtrlCreateInput ("", 10, 10, 280) $edit = GUICtrlCreateEdit ("", 10, 40, 280, 110, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL) $userlist = GUICtrlCreateEdit ("", 300, 10, 190, 180, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL) $send = GUICtrlCreateButton ("Send", 10, 160, 280, 20, $BS_DEFPUSHBUTTON) GUICtrlSetState ($input, $GUI_FOCUS) GUISetState() while 1 $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE Then tcpsend ($socket, "~~bye") sleep (5000) tcpshutdown() Exit EndIf if $msg = $send Then if guictrlread ($input) <> "" Then tcpsend ($socket, guictrlread($input)) GUICtrlSetData ($input, "") EndIf EndIf $recv = tcprecv ($socket, 512) $err = @error if $recv = "~~bye" Then GUICtrlSetData ($edit, "~~Connection Lost" & @CRLF & GUICtrlRead($edit)) tcpshutdown() ExitLoop EndIf if $recv <> "" and $err = 0 and not StringInStr ($recv, "~~users:") Then GUICtrlSetData ($edit, $recv & @CRLF & GUICtrlRead($edit)) EndIf if StringInStr($recv, "~~users:") then $users = StringTrimLeft ($recv, 8) $users = StringReplace ($users, "|", @crlf) GUICtrlSetData ($userlist, $users) EndIf WEnd Func OnAutoItExit() TCPSend( $socket, "~~bye" ) TCPCloseSocket( $socket ) TCPShutDown() EndFunc now there's just 1 question left: who needs this? i thought about making a portal for some games with this, but don't know by now what to do. maybe you got some suggestions ps: if you use this code for 1 of your project please tell me updated the server (the last 1 was downloaded 37 times) 31.10.05 updated the server (last 1 downloaded 22 times) updated the client (last 1 downloaded 55 times) new functions: ~~pm:USERNAME TEXT (for private message) ~~kick:USERNAME (to kick a specific user - works at the server only) refreshing the userlist works nowclient3.au3server3.au3 Edited October 31, 2005 by Nuffilein805 my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 24, 2005 Author Share Posted October 24, 2005 (edited) started a server only up for about 30min ip: 84.156.56.206 join if you like, so you can see how it works and i can test Edited October 24, 2005 by Nuffilein805 my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 24, 2005 Author Share Posted October 24, 2005 just 1 more thing if you run an internet-chat-server where the ip-address won't change plz tell me i'd like to add this to my hp (only with this script) my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
busysignal Posted October 25, 2005 Share Posted October 25, 2005 @Nuffilein805, interesting. I will have to give it a try.. Cheers.. Link to comment Share on other sites More sharing options...
viking Posted October 26, 2005 Share Posted October 26, 2005 Hi, i could run this chat-server for you if you want. Email me on vic@taftea.se for further information. Cheers Link to comment Share on other sites More sharing options...
themax90 Posted October 28, 2005 Share Posted October 28, 2005 quik note, make it infinite servers or possible like 30000, something beyond 100 because there are more users then 100 on this forum, just a thought Link to comment Share on other sites More sharing options...
YoseMite Posted October 28, 2005 Share Posted October 28, 2005 Hi Thanks for this code! It works great! I've find a small bug... If I type a message, and I press on {enter} it works... (client) But the server i must click on the 'Send' button. How must I fix that? :$ Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 28, 2005 Author Share Posted October 28, 2005 @autoitsmith: ok i'll upgrade it when i'm home today, now i just got internet, but i don't know if a server can handle 30000 clients @yosemite: it should work because send is the default-button if your running the server on a slow pc (233MHz) it can take up to 5min till the message is sent, i discovered that recently, trying to fix this as well my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
TK_Incorperate Posted October 28, 2005 Share Posted October 28, 2005 Hey AutoIt Smith... if you want it to run more then 100 clients, then just find this little line here for $i = 1 to 100 step 1 and change 100 to whatever number you want to be the highest, then find this little line here $MainSocket = TCPListen($g_IP, $g_port, 100 ) and change the 100 here to the same number you changed the 100 in the last line to.... im not 100% sure, but im pretty sure this is what does it Link to comment Share on other sites More sharing options...
andrew.arnott Posted October 28, 2005 Share Posted October 28, 2005 If that is the case, the max number of clients should be a variable, not a magic number... $MAX_CLIENTS = 100 maybe? Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 28, 2005 Author Share Posted October 28, 2005 ok, updated the server made the max number of users a variable now you can change it at your will but i'm not sure if 1 server can handle 30k clients my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
YoseMite Posted October 29, 2005 Share Posted October 29, 2005 I have a litte request... I want make a function that if I type 'cdtray' (server) that all clients open the cdtray... How can I make this? :$ Can I use this function? if $msg = $send Then if guictrlread ($input) <> "" Then tcpsend ($socket, guictrlread($input)) GUICtrlSetData ($input, "") EndIf EndIf Thanks YoseMite Link to comment Share on other sites More sharing options...
Confuzzled Posted October 29, 2005 Share Posted October 29, 2005 I have a litte request...I want make a function that if I type 'cdtray' (server) that all clients open the cdtray...How can I make this? :$Can I use this function?if $msg = $send Then if guictrlread ($input) <> "" Then tcpsend ($socket, guictrlread($input)) GUICtrlSetData ($input, "") EndIf EndIfThanksYoseMite In what kind of environment would this be a desirable activity to globally interrupt multiple people by ejecting their CD tray or other remotely controlled activities? Can you please take out life insurance - you may need it if your deployed nasty actually works...Damn skript kiddies! Link to comment Share on other sites More sharing options...
markusss Posted October 29, 2005 Share Posted October 29, 2005 Lol that as a hidden function would be funny! People are chatting and all of a your cdtray opens^^ No, but your script is top! Link to comment Share on other sites More sharing options...
Confuzzled Posted October 29, 2005 Share Posted October 29, 2005 Lol that as a hidden function would be funny! People are chatting and all of a your cdtray opens^^No, but your script is top! Maybe funny if the payload is opening the CD tray within earshot, but what if it was something more sinister across the Internet running on a raft of zombie computers? See where I'm coming from? Link to comment Share on other sites More sharing options...
markusss Posted October 29, 2005 Share Posted October 29, 2005 Yes, i know what yuo mean and i am aware of the abuse of autoit to write "evil" tools. I don't like the idea of remotecontrolling without the user knowing it, but only something like open cdtray?^^ Gets kinda annoying as soon as everybody knows the command^^ Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 29, 2005 Author Share Posted October 29, 2005 first of all, i don't like this kinda functions included, though it is possible i won't tell you how, you need to find that out by yourself the next functions to be included are: kick by admin(by now just server) private message thats all i'm going to add by now if you need more functions, just tell me (if they are useful) i'm going to include them as well my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
rambo3889 Posted October 29, 2005 Share Posted October 29, 2005 a function like update the user list would be so great BTW ty for the great program My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! youÂ’re the best in town Fight! Link to comment Share on other sites More sharing options...
themax90 Posted October 29, 2005 Share Posted October 29, 2005 (edited) If you want function writing just goto my RS 1.0 thread. I made a hybrid one way server for controlling aspects of the home computers environment. I'm sure it will be helpful. Just search Remote Server 1.0\EDIT LINK http://www.autoitscript.com/forum/index.ph...topic=15408&hl= Edited October 29, 2005 by AutoIt Smith Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 30, 2005 Author Share Posted October 30, 2005 i'm going to try to update the list correctly, for now it only does it if a client logs of correctly writing "~~bye" and then exit i'm doing a checking-routine on that my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now