Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/14/2012 in all areas

  1. This topic will contain simple and working client server communication example along with some basic info for understanding. Examples are based on multi client communication that is happening on one computer (localhost). Changing (if it's not already set correctly) the IP address parameter on server script to reflect your network device IP address will allow you to communicate with other clients on network or even to communicate on internet if your network settings (forwarded router port, ip address on that port is seen from others on internet, you're not trying to do client server from identical computer on identical internet connection) are configured correctly. Every client connecting will need to have server IP address for network (or server public IP address for internet) connection in his client script. So edit client script to correspond to server address TCPConnect('type server ip address in client', 1018). Sometimes firewall can be your problem, if something isn't working turn off firewall and see if it helps. Server will always listen on his Network Adapter IP Address and not on his public address. In some rare occasions server can be set to listen on 0.0.0.0, with that he will listen from any device that he have physically connected on his MB USB or something third (with localhost included for listening). But i would not know the end result of what will happen if some other program that you have installed need that port (or you started 2 servers that interpret one with another). First part will hold just plain code.Second part will hold identical code with comments below commands for more info and understanding hopefully to help new autoit users to understand what and why that something is there.Other parts will hold additional info.First part: Working Code (working in two way communication, with multiple and-or identical client)Server #include <Array.au3> TCPStartup() Dim $Socket_Data[1] $Socket_Data[0] = 0 $Listen = TCPListen(@IPAddress1, 1018, 500) If @error Then ConsoleWrite('!--> TCPListen error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPListen to get more info about this error.' & @CRLF) Exit EndIf While 1 For $x = $Socket_Data[0] To 1 Step -1 $Recv = TCPRecv($Socket_Data[$x], 1000000) If $Recv Then MsgBox(0, 'Client Number ' & $x & ' with connected socket identifier ' & $Socket_Data[$x], 'Recived msg from Client: ' & @CRLF & $Recv, 5) TCPSend($Socket_Data[$x], 'bye') TCPCloseSocket($Socket_Data[$x]) _ArrayDelete($Socket_Data, $x) $Socket_Data[0] -= 1 EndIf Next _Accept() WEnd Func _Accept() Local $Accept = TCPAccept($Listen) If $Accept <> -1 Then _ArrayAdd($Socket_Data, $Accept) $Socket_Data[0] += 1 EndIf EndFunc ;==>_AcceptClient TCPStartup() $Socket = TCPConnect(@IPAddress1, 1018) If @error Then ConsoleWrite('!--> TCPConnect error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPConnect to get more info about this error.' & @CRLF) Exit EndIf TCPSend($Socket, 'Hi there. My computer name is' & ", " & @ComputerName & ", and its drive serial is " & DriveGetSerial(@HomeDrive)) Do $Recv = TCPRecv($Socket, 1000000) Until $Recv MsgBox(0, 'Recived from server:', $Recv)Second part: Explained Working Code (for upper communication) Third Part: Understanding for how is msg received with TCPRecv on server (or on client) Forth Part: Packets Fifth Part: How to get or check IP address of your device? Sixth Part: How to forward ports? (2 nice youtube tutorials) Seventh Part: Internet communication? If i wrote something incorrectly or wrong please tell me so that i can correct it. Edited: Local and Global, added aditional info about reciving msgs for maxlen buffer.
    1 point
  2. MsgBox( 0, "", _Numbers( ) ) Func _Numbers( ) Local $array[101] Local $count = 0 For $i = 1 To 100 $array[$i] = Random( 0, 100 ) $count += $array[$i] Next Return $count / 100 EndFunc Something like this?
    1 point
  3. newuser123, I am afraid the "retard" is not at this end of the conversation. Your username has been re-adjusted and you are now permanently banned. M23
    1 point
  4. llewxam

    CSV Viewer

    First post updated, now using czardas' UDF as well as copied Melba23's StringSize UDF in to the script for ease of use. Thanks all for the suggestions, more revisions may come. Ian
    1 point
  5. ProgAndy

    CSV Viewer

    I know why my UDF does not work with your file. First, it creates an array which can hold all available fields as single records, afterwards it adds a column if required and does not reduce allocated space in the first dimension. This is done only at the very end.To fix that, you'll have to cut down the record count of the array when adding an additional column which forces some more error checking in return. Edit: improved wording. I have a fixed version and currently am running some tests with openURL routing data.
    1 point
  6. @yo3575 oh... you need to learn the basics first so. Take a look at the help file from the beginning and there is some threads in this forum section to learn autoit. Just tape "Send" in an au3 script and press F1 for the help according to this func. Br, FireFox.
    1 point
×
×
  • Create New...