vdankbaar Posted August 17, 2015 Share Posted August 17, 2015 (edited) Hi everyone,Its my first time on the fourm so take it easy on me if i make some mistakes.I recently started programming with Auto it but I'm having some trouble with arrays.I'm making a tcpchat and I have made a client and server script.Everything works exept for when the client sends some text to the server.The idea is that the server sends the text to all the clients, But I can't figure out how to use tcpsend with a array (Keep in mind that I want to send the text to the whole array aka. all the clients).Here is the code i have at the moment. If the solution is simple then i'm sorry but i wasen't able to find anything on the subject.;this is my code (the server)#include <Array.au3>setup()sender()afsluiten()func setup()Global $clientcount=0global $ip=InputBox("Chatservice", "voer je eigen ip in")global $port=InputBox("Chatservice", "voer een port in tussen 1000-6500 om op te hosten")global $maxusers=InputBox("Chatservice", "hoeveel mensen mogen maximaal mee chaten")TCPStartup()Dim $Socket_Data[$maxusers]$Socket_Data[0] = 0$Listen = TCPListen($ip, $port, $maxusers)While 1 For $x = $Socket_Data[0] To $maxusers Step -1 global $Recv = TCPRecv($Socket_Data[$x], 4096) Next _Accept()WEndFunc _Accept() Local $Accept = TCPAccept($Listen) If $Accept <> -1 Then _ArrayAdd($Socket_Data, $Accept) $Socket_Data[0] += 1 EndIfEndFuncendfuncfunc sender()While 1if $Recv then;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/;here is the problem;i want $clients to include the whole array but it doesn'tTCPSend($clients, $Recv);/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\endifWEndEndFuncFunc afsluiten() TCPSend($isock2, $recv) TCPCloseSocket($isock) TCPCloseSocket($Socket1) TCPCloseSocket($isock2) TCPCloseSocket($Socket2) TCPCloseSocket($client1) TCPCloseSocket($client2) TCPShutdown()EndFunc Edited August 17, 2015 by vdankbaar Link to comment Share on other sites More sharing options...
water Posted August 17, 2015 Share Posted August 17, 2015 For $i = 1 to $clients[0] ; When the array holds the number of entries in the first element For $i = 0 to UBound($clients) - 1 ; When the array doesn't hold the number of entries in the first elementOne of this two should do the trick My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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