taurus905 Posted February 11, 2010 Share Posted February 11, 2010 I am looking for a simple solution to accomplish the following: Client application – located on various PCs. (AutoIt Exe) Server application – located on Internet server. (AutoIt Exe or C# Exe) Database – located on same Internet server. (MS SQL) Client application sends a string to Server application. Server application reads Database, makes calculations and then writes to Database. Server application sends string to Client application. Thank you in advance for any suggestions. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
jchd Posted February 11, 2010 Share Posted February 11, 2010 ODBC or ADO will do nicely.ADOODBC This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
taurus905 Posted February 12, 2010 Author Share Posted February 12, 2010 ODBC or ADO will do nicely.ADOODBCHello jchd,Thank you for the links.I read lots of posts on TCP and feel this might be the way to go. But I think I will start off without a database to simplify matters a bit.So is the following possible and would I need to use TCP or is there a better option?Internet server has an AutoIt Exe named Server.exeMy PC has an AutoIt Exe named Client.exeHow can Client.exe send a string to Server.exe, do some calculations and return another string?Thank you to anyone who can help me understand what I need to do.taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
jchd Posted February 12, 2010 Share Posted February 12, 2010 I read lots of posts on TCP and feel this might be the way to go. But I think I will start off without a database to simplify matters a bit. So is the following possible and would I need to use TCP or is there a better option? Internet server has an AutoIt Exe named Server.exe My PC has an AutoIt Exe named Client.exe How can Client.exe send a string to Server.exe, do some calculations and return another string? Thank you to anyone who can help me understand what I need to do. taurus905 It really depends on what the "calculations" part is and wether or not there will be only one client or several. The whole point of a [R]DBMS ([relational] database management system) is to hide the gory details of records storage and organization (indexing and the like), details about locking protocols so that several users can use the database pseudo-simultaneously and eventually offer the applications a high-level language --SQL is proeminent-- to filter, sort, merge... data on demand without big hassle. Applications range from lightweight mobile (mobile phones, PDA, ...) to datacenters (Google, Amazon, ...). Probably the most deployed RDBMS found in the whole range is SQLite which is very efficient, free, zero-administration and open-source. AutoIt has support for it in its standard release. If you are in a peer-to-peer situation (only one client and one server) then it may be the right choice if the server has something to store, retrieve on demand using simple or more complex criterions. ODBC or its newer layer (ADO) is a standardized high-level interface which makes easier to switch from one database to another by offering a uniform SQL syntax (there are small to large "dialect" variations among various rDBMS vendors). This is an oversimplification. OTOH, a simple network link is another beast. You have TCP connection example eveywhere in the forum (use search) or named-pipes connection example in standard AutoIt: look in the help file and in the \Program Files\AutoIt3\Examples\GUI\Advanced directory. This approach is of course more pedestrian and you're on your own to determine what and how data should be sent/received, monitor the various error conditions and the like. Also don't expect any form of advanced storage to be bundled with what is only a simple communication link. Comparing TCP and a DBMS is a bit like comparing a modem and a web browser. If your need is simple then TCP/modem (bare bones communication link) with some home brew convention (protocol) can be just fine. If you need something significantly less basic, then something more advanced will save your life. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
taurus905 Posted February 12, 2010 Author Share Posted February 12, 2010 I have spent many hours today reading TCP posts on the forum which pertain to my simple request of Client.exe to send a string across the Internet to Server.exe and then returning another string back to Client.exe but have not found what I need yet. Many of the examples are old and the scripts are no longer valid. But I am not looking for someone to do my scripting. I only need to be pointed to the right commands to use. I don’t plan on tackling the database part of my solution until I solve the communication issue between the client/server applications. I will keep searching and look forward to any other suggestions. Thank you for your time. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Hawkwing Posted February 12, 2010 Share Posted February 12, 2010 (edited) Try this out Server code TCPStartup() $socket = TCPListen(@IPAddress1, 1111) While 1 $ConnectedSocket = TCPAccept($socket) If $ConnectedSocket >= 0 Then ConsoleWrite("Connected" & @CRLF) ExitLoop EndIf WEnd While 1 $data = TCPRecv($ConnectedSocket, 10000) If $data <> "" Then ConsoleWrite($data & @CRLF) If $data = "Exit" Then TCPShutdown() Exit EndIf WEnd Client code #include<guiconstants.au3> #include<guiipaddress.au3> Opt("guioneventmode", 1) $gui = GUICreate("Test", 125, 40) GUISetOnEvent($GUI_EVENT_CLOSE, "close") $ipbox = _GUICtrlIpAddress_Create($gui, 0, 0) _GUICtrlIpAddress_Set($ipbox, "0.0.0.0") $button = GUICtrlCreateButton("Go", 0, 25, 125, 15) GUICtrlSetOnEvent(-1, "go") GUISetState() TCPStartup() While 1 Sleep(100) WEnd Func go() $socket = TCPConnect(_GUICtrlIpAddress_Get($ipbox), 1111) GUIDelete($gui) While 1 TCPSend($socket, InputBox("", "")) WEnd EndFunc Func close() Exit EndFunc Edited February 12, 2010 by Hawkwing The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
taurus905 Posted February 12, 2010 Author Share Posted February 12, 2010 Hello Hawkwing, Thank you for the examples. I was able to get them working. I finally have something to build on. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
taurus905 Posted February 12, 2010 Author Share Posted February 12, 2010 After spending all day researching TCP/IP, I have one simple question: Is it possible for a client and a server to both send and receive? If so, please provide a few keywords which I can search for online. Thank you, taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
yucatan Posted February 12, 2010 Share Posted February 12, 2010 After spending all day researching TCP/IP, I have one simple question:Is it possible for a client and a server to both send and receive?If so, please provide a few keywords which I can search for online.Thank you,taurus905yes is possiblethat client and server both send and recieve. Link to comment Share on other sites More sharing options...
taurus905 Posted February 12, 2010 Author Share Posted February 12, 2010 Thank you for your reply, yucatan. It took me all night and about every TCP script on this forum, plus digging for information on the Internet to figure that out. I read the opposite somewhere, but am so glad that is not true. Now I need to do lots of testing to get it to do what I need. But first, I am going to eat and get some sleep. This was like pulling teeth. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
taurus905 Posted February 14, 2010 Author Share Posted February 14, 2010 As it turns out, TCP was not the solution I was looking for. But I thought I would post these examples because there are so many unanswered TCP questions in this forum. I believe IIS will be what I need since my website is hosted by GoDaddy and I don't have a dedicated IP.TCP Server:#include "TCP.au3" Opt("MustDeclareVars", 1) Dim $hServer = _TCP_Server_Create(56453, @IPAddress1) ; Create Server Socket ToolTip("SERVER is Running.", 10, 20) _TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NEWCLIENT") ; Called when new client connects. _TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Received") ; Called when data is received. While 1 Sleep(100) WEnd Exit Func NEWCLIENT($hSocket, $iError) ; New Client connected to server. Sleep(5000) ; Time to do calculations. _TCP_Send($hSocket, "Server sent reply.") EndFunc ; ==> NEWCLIENT Func Received($hSocket, $sReceived, $iError) ; Called when data is received. ToolTip("SERVER: " & $sReceived, 10, 50) EndFunc ; ==> ReceivedTCP Client:expandcollapse popup#include "TCP.au3" Opt("MustDeclareVars", 1) HotKeySet("{ESC}", "Exit_Program") HotKeySet("{F2}", "Send_Data") Dim $hClient = _TCP_Client_Create(@IPAddress1, 56453) ; Create Client Socket _TCP_RegisterEvent($hClient, $TCP_CONNECT, "Connected") ; Called when client is connected. _TCP_RegisterEvent($hClient, $TCP_RECEIVE, "Received") ; Called when data is received. While 1 Sleep(100) WEnd Exit Func Connected($hSocket, $iError) ; Called when client connects. Switch $iError Case True ToolTip("CLIENT: Could not connect. Check if server is running.", 200, 50) Case Else ToolTip("CLIENT is Connected.", 200, 20) _TCP_Send($hSocket, "Client sent data") EndSwitch EndFunc ; Connected Func Received($hSocket, $sReceived, $iError) ; Called when data is received. ToolTip("CLIENT: " & $sReceived, 200, 50) EndFunc ; ==> Received Func Send_Data() ; Send Data _TCP_Send($hClient, "Client input refreshed.") EndFunc ; ==> Send_Data Func Exit_Program() ; Exit Program _TCP_Server_DisconnectClient($hClient) Exit EndFunc ; ==> ExitDownload the TCP.au3 include file from here:TCP UDF, Event driven! Version 3TCP UDF, Event driven! Version 3 was written by Kip and he did a great job.taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs 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