steve8tch Posted February 23, 2006 Share Posted February 23, 2006 I have written a script that updates a sockets application written some time ago in C. (I could not track down a problem - but it was not 100% reliable with new PCs running WinXP SP2) - I have ported the application over to AutoIT and it appears to run without problems.This application talks to production machinery - and while it works - I would like to understand more a couple of the tcp settingsTCPRecv ( socket, maxlen ) - max # of characters to receiveI have set this to 2048 in my app because on occassions - a stream of 1400 charactors could be recieved - although more usually the stream would be about 150 charactors. Is there any 'good practice' regarding this value - to avoid problems.When testing I had set this value to 512 - send a stream of 600 charactors and the last 80 odd charactors gets truncated. Does - AutoIt then clear out the buffer so any information after this limit is lost - or should it be available for a second read of the buffer.What is the maximum / minimum buffer size.Can you continually read in from the buffer - one charactor at a time.The other one I would like some more info on is - TCPListen ( IPAddr, port [, MaxPendingConnection] ) - Maximum length of the queue of pending connections. By default the maximun reasonable value will be set. - what does this mean and what are the implications of certain settings.I have more questions about this - but is if someone is able to explain a little - that would really help.Thanks.Sorry about the boring post :"> Link to comment Share on other sites More sharing options...
Valuater Posted February 23, 2006 Share Posted February 23, 2006 have you taken a look at this posthttp://www.autoitscript.com/forum/index.php?showtopic=20589#i know nada about TCP... sorry8) Link to comment Share on other sites More sharing options...
themax90 Posted February 23, 2006 Share Posted February 23, 2006 (edited) I wrote the article and alot of examples, check my signature or my friend Valuater's above post. To allow all possibilities, you should always have a variable like: Global $MaxLength = 512; Or any other number I often set it too 512000 because you never know what amount will come through streams. As for when you send too much, it is read then if you go over the maximum characters it USUALLY is picked up upon the second recv command as long as no other instance is sent in that .005 odd fraction of a second(if you made you TCP script correctly). Maximum buffer size : That is not completely known but the size is proportional to the amount of memory used. Consult the Helpfile on limitations too find it that is availible. Presumably, since you may get extra values that exceeded the maximum length, you could in theory, read character by character. I have NEVER attempted this and see no need for it, so you may attempt it, please check once again, the list of examples for the Optimized Server /w Client and modify the Client's accepting variable to 1 and see if it works. Maximum Connections : Basically, if you do not have it set, then the amount of connections is not set and only limited by the amount of variables you can use or how much you can keep track of. Maximum connection basically inforces a rule that if you exceed the MaxConc setting then your connection is refused. I do not know specifics, I have never tested it that far. Any and all questions, please post here for I will link this too my other thread for other questioneers. - AutoIt Smith Edited February 23, 2006 by AutoIt Smith Link to comment Share on other sites More sharing options...
steve8tch Posted February 23, 2006 Author Share Posted February 23, 2006 Thankyou for your helpful replies. Yes I did look at all these examples - I had to set up servers and clients to do all my testing - it was all based on the examples created by @AutoIt Smith. The problem is - it works !!! ..but if it stopped working - in a production enviroment I would need to find solutions very quicky. Thats why I am quite keen to find out what is best practice in this area - what settings can I use to get what I need - but avoid any unforseen issues that I don't know about - because - I do not know what is the best practice in this area. MaxPendingConnection - does this mean that up to 10 (eg) streams can be send to the same port at the same time - and these streams can be read off one at a time with separate calls to "TCPRecv" - or would tcp recieve them all at once. What is the optimum polling time for TCPAccept. eg - if you polled 1x per second - if 10 'messages' or 'streams' had been received during that time - would you just loop through TCPRecv 10x to pick them all up - or is it best to poll every 1ms for example to see if anything is there. AutoIt Smith mentioned setting MaxLen to 512000 - Does this mean that you could have say 1000 MaxPendingConnections - each allocated space for 512000 charactors - can WinXP cope with that or would you need a server environmet. Sorry - for all the questions - if I knew the answers I wouldn't be asking the questions :"> If anyone could write a brief summary of what these settings mean in practice - that would be very helpful. Thanks again for your help. Link to comment Share on other sites More sharing options...
Sokko Posted February 23, 2006 Share Posted February 23, 2006 Memory space for pending connections and receiving data should be dynamically allocated, the number you input is just an arbitrary cap (and in the case of maxpendingconnection you can even leave it out to have no cap at all). I have set both values to ridiculously high amounts and it has had no noticeable effect on processing speed or memory footprint.What is the optimum polling time for TCPAccept. eg - if you polled 1x per second - if 10 'messages' or 'streams' had been received during that time - would you just loop through TCPRecv 10x to pick them all up - or is it best to poll every 1ms for example to see if anything is there.I'm not quite sure what you mean here... TCPAccept has nothing to do with receiving data. Assuming that was a typo and you meant "TCPRecv": Yes, if you did a TCPRecv once per second and 10 data blocks were sent in the same second, it would pick them up one at a time in order and after 10 seconds you'd have gotten them all. However, I would highly recommend doing TCPRecv "as fast as possible" in any case, so you'll always stay on top of the incoming data. What if 10 more data blocks were sent in the next second? And 10 more in the second after that? Now it's taking you half a minute to pick up all those messages. Link to comment Share on other sites More sharing options...
themax90 Posted February 23, 2006 Share Posted February 23, 2006 What he means is can he just use the MainSocket variable to recieve all transmissions of that port. The answer is no, if you check out my Optimized server. Notice you must check EVERY variabled socket connect in order to recv it. $Track = 0 For $Track = 0 To $MaxConnection Step 1 $Data = TCPRecv($ConnectedSocket[$Track], $MaxLength) AnalyzeData($Data) Next - AutoIT Smith 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