Sign in to follow this  
Followers 0
Akarillon

[Solved]TCP Multitasking

10 posts in this topic

#1 ·  Posted (edited)

Is it possible to make 1 script receive information from 2 different sources via TCPRecv at the same time?

And if it is, how?

Or maybe I have to make a queue, like having the second computer wait until the first is completed?

At the moment I am using a Do loop on 1 TCPAccept token.

Do
   $KlientRecv1 = TCPRecv($TCPAccept, 2048)
  Until $KlientRecv1 <> ""
  GUICtrlSetData($Input1x, $KlientRecv1)
  _WriteToLog(GuiCtrlRead($Label1), $KlientRecv1)

Can post code if necessary.

Edited by Akarillon

Challenge accepted!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Not without multi-threading. It was noted in another forum *I meant thread*, that if you know the command-line command to recieve the information, you could do so, both at the same time.

Edited by Mikeman27294

Share this post


Link to post
Share on other sites

understanding more and more every day.. thanks :D


Challenge accepted!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

TCPListen allows to specify a queue length for pending connections (and has a reasonable default value). So you can't handle two connections at the same time but one after the other. Give it a try.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

TCPListen allows to specify a queue length for pending connections (and has a resonable default value). So you can't handle two connections at the same time but one after the other. Give it a try.

Ye, that was my plan B :D

Plan C would be several executables.


Challenge accepted!

Share this post


Link to post
Share on other sites

Why do you want to process connections in parallel or run several executables? Do you have so many clients connecting at the same time? Or does processing the pakets take so much time that it would block other connections for too long?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Why do you want to process connections in parallel or run several executables? Do you have so many clients connecting at the same time? Or does processing the pakets take so much time that it would block other connections for too long?

I was planning on using this as an Inventory-software that receives information about computers every day at 6 o'clock exactly from over 400 computers..

Thought it would take forever to make a queue of them all


Challenge accepted!

Share this post


Link to post
Share on other sites

My understanding is that the queue is handled by the TCP stack itself. You listen on the socket, take the incoming data and process it. Then you receive the next paket, process it and so on. The pakets arriving during your processing of another clients data is queued by TCP.

If the queue overflows you raise the number in TCPListen.

Or you can extract the processing of the data into a separate AutoIt script, compile it and use Run to process the data. This way you can run multiple "processing" exe's in parallel. This depends on how your inventory system (database ...?) can handle parallel data input. If you need to send some feedback to the client when done it gets a bit more complex.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

My understanding is that the queue is handled by the TCP stack itself. You listen on the socket, take the incoming data and process it. Then you receive the next paket, process it and so on. The pakets arriving during your processing of another clients data is queued by TCP.

If the queue overflows you raise the number in TCPListen.

Or you can extract the processing of the data into a separate AutoIt script, compile it and use Run to process the data. This way you can run multiple "processing" exe's in parallel. This depends on how your inventory system (database ...?) can handle parallel data input. If you need to send some feedback to the client when done it gets a bit more complex.

I think I'll stay on the easy part of programming for the moment :D

Can the TCPListen handle incoming connections even if the script is occupied in a do-loop?


Challenge accepted!

Share this post


Link to post
Share on other sites

Yes, that's what the queue is for.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0