McGod Posted June 21, 2007 Share Posted June 21, 2007 This is a simple and easy to adapt server that can support multiple users on it.Some features:Stores all information in a single easy to access arrayIs able to disconnect people on idle by using _DateDiff()expandcollapse popupTCPStartup () #include <Date.au3> #include <Array.au3> Global ÌÍÒYU[Y[Ý]HMNÈ[YH[Z[]È[[HÙÈØÛÛXÝYÜZærFÆæp¤vÆö&Âb33c´FG&W72ÒFG&W73´÷RvçBFòÆ7FVâg&öФv½°ÀÌØíA½ÉÐôÐäääíA½ÉÐå½ÕȽ¥¹Ñ¼±¥ÍѸ½¸)±½°ÀÌØí5á1¸ôÐ00 Global $Users[1][3] Global $sock = TCPListen($IpAddress, ÌÍÔÜ BYÜ[^]ÙÐÞ K ][ÝÕÔÙÜ][ÝË ]÷C´fÆVBFòÆ7FVâÂF26÷VÆB&RGVRFò&öw&ÒÇ&VGÆ7FVææröâFÐÁ½ÉиÅÕ½Ðì¤()]¡¥±Ä(} ¡9ÝUÍÉÌ ¤(}IØ ¤)]¹()Õ¹} ¡NewUsers () Local $sSock = TCPAccept ($sock) If $sSoÚÈHLH[]ØØ[ ÌÍÙHPÝ[ ÌÍÕÙËJJÌBQ[b33cµW6W'5²b33c¶EÕ³5Тb33cµW6W'5²b33c¶BÓÕ³ÒÒb33c·56ö6°¢b3ÌØíUÍÉÍlÀÌØí´ÅulÅtô}9½Ý ± ¤(ÀÌØíUÍÉÍlÀÌØí´ÅulÉtôM½ÑoIP($sSock) Return 1 EndFunc Func _Recv () For $i = 1 ToPÝ[ ÌÍÕÙÊHLHÝB ÌÍÜÝHÔXÝ ÌÍÕÙÖÉÌͶճÒÂb33c´ÖÆVâ¢bW'&÷"FVâWDÆö÷ôF62b33c¶¢%ÀÌØíÉØôÅÕ½ÐìÅÕ½ÐìQ¡¸(%}Ñ¥ ÅÕ½Ðí¸ÅÕ½Ðì°#036;Users[$i][1], _NowCalc ()) >= $IdleTimeout Then ÑØÊ ÌÍÚJB^]ÛÜ[Y6öçFçVTÆö÷¢VæD`¢õ'6U&WBb33cµW6W'5²b33c¶Õ³ÒÂb33íÉؤ(9áÐ)¹Õ¹()Õ¹}¥Í ÀÌØí¤¤(Q A ±½ÍM½Ð ÀÌØíUÍÉÍl#036;i][0]) _ArrayDelete2D($Users, $i) Return 1 EndFunc [ÈÔÙT] ÌÍÝÙ ÌÍÜXÝBY ÌÍÜXÝH ][ÝÚI][ÝÈVà¢D56VæBb33c·W6W"ÂgV÷C¶VÆÆògV÷C²¢VæD`¤VæDgVæ0 £²gVæ7¥½¸Ñ¼ÉÑÕɸ%@ÉÍÌɽ´½¹¹Ñͽи(ì´´´´´´´´´´´´´´´´´´´´´´´´--------------------------------------------- Func SocketToIP($SHOCKETBØØ[ ÌÍÜÛØÚØYHÝXÝÜX]J ][ÝÜÚÜÝÚÜÝZ[ØÚÎgV÷C² ¢Æö6Âb33c¶&WBÒDÄÄ6ÆÂgV÷Cµw3%ó3"æFÆÂgV÷C²ÂgV÷C¶çBgVÐì°ÅÕ½ÐíÑÁɹµÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØíM!= -P°|(ÅÕt;ptr",DLLStructGetPtr($sockaddr),"int_ptr",DLLStructGeÚ^J ÌÍÜÛØÚØYJBYÝÜ[ ÌÍØT]ÌHH[b33c¶&WBÒDÄÄ6ÆÂgV÷Cµw3%ó3"æFÆÂgV÷C²ÂgV÷C·7G"gV÷C²ÂgV÷C¶æWEöçFöÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì±11MÑÉÕÑÑÑ ÀÌØíͽȰ̤¤(%9½Ðror Then $aRet = $aRet[0] Else $aRet = 0 EndY ÌÍÜÛØÚØYH] ÌÍØT][[Â[ÈÐ^Q[]$B'&Vbb33c¶d'&Âb33c¶VÆVÖVçB¢Æö6Âb33c·76VBÒfÇ6P¢¢%¡9½Ð%ÍÉÉä ÀÌØíÙÉÉ䤤Q¡¸(MÑÉÉ½È Ä¤(IÑÕɸquot;" EndIf ; We have to define this here so that we'HÝH] ÌÍØ]^HÈ[^BÈYÜHÙHÙ]] ÌÎNÜÈÚ^Kb33c¶WW"ÒT&÷VæBb33c¶d'&²6¦Röb÷&væÂ'&¢b33í¥MÕ%ѵÌôU½Õ¹ ÀÌØíÙÉÉä°È¤((ì%Ñ¡ÉÉä¥Ì½¹±äıµt in size then we can't delete the 1 element. If $iUpper = 1 T[Ù]ÜB] ][ÝÉ][ÝÂ[YØØ[b33c¶dæWt'&²b33c¶WW"ÒÕ²b33c¶7V$FV×5Ð ¢f÷"b33c¶ÒFòÀÌØí¥UÁÁÈ´Ä(%ÀÌØíôÀÌØí¥±µ¹ÐÑ¡¸(ÀÌØpassed = True Else If Not $passed then Ü ÌÍØHÈ ÌÍÚTÝX][ÈHB ÌÍØ]]Ð'&²b33c¶Õ²b33c¶%ÒÒb33c¶d'&²b33c¶Õ²b33c¶%ТæWÐ(±Í(½ÈÀÌØíôÀѼÀÌØí¥MÕ%ѵ̴Ä( $avNewArray[$a - 1][$b] = $avArray[&#ÍØWVÉÌÍØB^[Y[Y^@¢¢b33c¶d'&Òb33c¶dæWt'& ¢&WGW&â¤VæDgVæ0 [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
JohnBailey Posted August 8, 2007 Share Posted August 8, 2007 Evidentially, nobody else seems to be having this issue... I don't understand how this is used for the client A decision is a powerful thing Link to comment Share on other sites More sharing options...
Hostage Posted August 8, 2007 Share Posted August 8, 2007 (edited) I wrote a similar server, but I went with an ADOR recordset (which I think is somewhat more simple). I'll post the relevant sections. Globals: expandcollapse popup;tcp stuff TCPStartup() Const $fwpsrv_port = 4000 Const $fwpsrv_max_connections = 100 Global $fwpsrv_MainSocket = TCPListen(@IPAddress1, $fwpsrv_port, $fwpsrv_max_connections) if $fwpsrv_MainSocket = -1 Then msgboX(0, "Failed to Startup", "Failed to open socket on port " & $fwpsrv_port) Exit endif ;global variables global $gui_status_listview global $fax_timer = -1 global $email_timer = -1 ;sockets recordset $fwpsrv_sockets_id = 0 $fwpsrv_sockets_count = 0 $fwpsrv_sockets = ObjCreatE("ADOR.recordset") $fwpsrv_sockets.fields.append("ID", $adInteger) $fwpsrv_sockets.fields.append("Socket", $adVarWChar, 10) $fwpsrv_sockets.fields.append("User ID", $adInteger) $fwpsrv_sockets.fields.append("Timer", $adVarWChar, 255) $fwpsrv_sockets.fields.append("User Name", $adVarWChar, 50) $fwpsrv_sockets.Open ;messages recordset $fwpsrv_messages_id = 0 $fwpsrv_messages_count = 0 $fwpsrv_messages = ObjCreate("ADOR.RecordSet") $fwpsrv_messages.fields.append("ID", $adInteger) $fwpsrv_messages.fields.append("Socket ID", $adInteger) $fwpsrv_messages.fields.append("User ID", $adInteger) $fwpsrv_messages.fields.append("Message", $adVarWChar, 255) $fwpsrv_messages.OpenoÝ÷ Ù8^±êïz¶®¶sdgVæ2euôÖW76vTÆÂb33c¶ÖW76vR euôÆörgV÷C´vÆö&ÂÖW76vS¢gV÷C²fײb33c¶ÖW76vR bb33c¶gw7'e÷6ö6¶WG5ö6÷VçBfwC²FVà b33c¶gw7'e÷6ö6¶WG2äÖ÷fTf'7@ vÆRæ÷Bb33c¶gw7'e÷6ö6¶WG2äTô` ¶6V6²f÷"vFærFF D56VæBb33c¶gw7'e÷6ö6¶WG2æfVÆG2gV÷Cµ6ö6¶WBgV÷C²çfÇVRÂgV÷C´ÖW76vW2gV÷C²fײ5$Äbfײb33c¶ÖW76vR euôÆörb33c¶gw7'e÷6ö6¶WG2æfVÆG2gV÷Cµ6ö6¶WBgV÷C²çfÇVRfײgV÷C³¢ÖW76vR6VçBgV÷C² b33c¶gw7'e÷6ö6¶WG2äÖ÷fTæW@ tVæ@ VæF`¦VæFgVæ0 ¤gVæ2euôÖW76vT6V6²b33c·W6W"Âb33c·W6W%öBÂb33c·6ö6¶WB b33c·'2Òö&¤7&VFRgV÷C´DôD"ç&V6÷&G6WBgV÷C² b33cµ'2æ7W'6÷'GRÒb33c¶D÷Vä¶W6W@ b33c·'2æÆö6·GRÒb33c¶DÆö6´÷FÖ7F0 £¶6V6²FRÆW'G2F&ÆP b33c·'2ä÷VâgV÷Cµ4TÄT5B¢e$ôÒ´ÆW'G5ÒtU$RµW6W%ÒÒb33²gV÷C²fײb33c·W6W"fײgV÷C²b33²äB´F6Ö76VEÒ2åTÄÂgV÷C²Âb33c¶æWt6öâ b33c·FWBÒgV÷C´ÖW76vW2gV÷C²fײ5$Ä` bæ÷Bb33c·'2äTôbFVà euöÆörgV÷Cµ6VçBÖW76vW2FògV÷C²fײb33c·W6W" vÆRæ÷Bb33c·'2äTô` b33c·FWBf׳Òb33c·'2æfVÆG2gV÷C´ÆW'EFWBgV÷C²çfÇVRfײ5$Ä` b33c·'2æfVÆG2gV÷C´F6Ö76VBgV÷C²Ò b33c·'2åWFFP b33c·'2äÖ÷fTæW@ vVæ@ Fð D56VæBb33c·6ö6¶WBÂ7G&ævÆVgBb33c·FWBÂ#SR b33c·FWBÒ7G&æwG&ÖÆVgBb33c·FWBÂ#SR VçFÂb33c·FWBÒgV÷C²gV÷C° VæF` b33c·'2ä6Æ÷6P b33c·'2ÒgV÷C²gV÷C°¦VæFgVæ0¤gVæ2euõD5ô6V6²£¶6V6²f÷"æWr6öææV7Föç0 b33c·FV×ÒD566WBb33c¶gw7'eôÖå6ö6¶WB bb33c·FV×fÇC²fwC²ÓFVà b33c·&VE÷W6W%öBÒD5&V7bb33c·FV×Â#SR b7G&ævç7G"b33c·&VE÷W6W%öBÂgV÷C´eu¢gV÷C²FVà b33c·&VE÷W6W%öBÒ7G&æw&WÆ6Rb33c·&VE÷W6W%öBÂgV÷C´eu¢gV÷C²ÂgV÷C²gV÷C² VæF` bb33c·&VE÷W6W%öBfÇC²fwC²gV÷C²gV÷C²æB7G&æt4çBb33c·&VE÷W6W%öBFVâ ¶FBFò&V6÷&G6W@ b33c¶gw7'e÷6ö6¶WG5öB³Ò b33c¶gw7'e÷6ö6¶WG5ö6÷VçB³Ò b33c¶gw7'eõ6ö6¶WG2äFDæWp b33c¶gw7'e÷6ö6¶WG2æfVÆG2gV÷C´BgV÷C²Òb33c¶gw7'e÷6ö6¶WG5ö@ b33c¶gw7'e÷6ö6¶WG2æfVÆE2gV÷Cµ6ö6¶WBgV÷C²Òb33c·FV× b33c¶gw7'e÷6ö6¶WG2æfVÆE2gV÷CµW6W"BgV÷C²Òb33c·&VE÷W6W%ö@ b33c¶gw7'e÷6ö6¶WG2æfVÆE2gV÷CµW6W"æÖRgV÷C²ÒW6W$g&öÔBb33c·&VE÷W6W%öB b33c¶gw7'e÷6ö6¶WG2æfVÆE2gV÷CµFÖW"gV÷C²ÒFÖW&æB ·6VæB&6²&VBW6W"Bf÷"6öæf&ÖFöâFò6ÆVç@ D56VæBb33c¶gw7'e÷6ö6¶WG2æfVÆE2gV÷Cµ6ö6¶WBgV÷C²çfÇVRÂgV÷C´eu¢gV÷C²fײb33c·&VE÷W6W%öB euôÆörgV÷C´6öææV7Föâg&öÒgV÷C²fײb33c¶gw7'e÷6ö6¶WG2æfVÆG2gV÷CµW6W"æÖRgV÷C²çfÇVRfײgV÷C²öâ6ö6¶WBgV÷C²fײb33c·FV× VÇ6P D56Æ÷6U6ö6¶WBb33c·FV× euôÆörgV÷C´6öææV7Föâ&÷'FVBöâ6ö6¶WBgV÷C²fײb33c·FV× VæF` VæF` £¶6V6²W7Fær6öææV7Föç0 bb33c¶gw7'e÷6ö6¶WG5ö6÷VçBfwC²FVà b33c¶gw7'e÷6ö6¶WG2äÖ÷fTf'7@ vÆRæ÷Bb33c¶gw7'e÷6ö6¶WG2äTô` ¶6V6²f÷"vFærFF b33c·FV×ÒD5&V7bb33c¶gw7'e÷6ö6¶WG2æfVÆG2gV÷Cµ6ö6¶WBgV÷C²çfÇVRÂ#SR bb33c·FV×fÇC²fwC²gV÷C²gV÷C²FVà b33c·W6W%öBÒb33c¶gw7'e÷6ö6¶WG2æfVÆG2gV÷CµW6W"BgV÷C²çfÇVP b33c·W6W"ÒW6W$g&öÔBb33c·W6W%öB bb33c·FV×ÒgV÷C´ÖW76vW2gV÷C²FVâ D56VæBb33c¶gw7'e÷6ö6¶WG2æfVÆG2gV÷Cµ6ö6¶WBgV÷C²çfÇVRÂgV÷CµöærgV÷C²£·âeuôÆörgV÷C´ÖW76vR6V6²f÷"gV÷C²fײb33c·W6W" euôÖW76vT6V6²b33c·W6W"Âb33c·W6W%öBÂb33c¶gw7'e÷6ö6¶WG2æfVÆE2gV÷Cµ6ö6¶WBgV÷C²çfÇVR VÇ6P euöÆörb33c·W6W"fײgV÷C³¢6VçBföÆÆ÷væs¢gV÷C²fײb33c·FV× VæF` b33c¶gw7'e÷6ö6¶WG2æfVÆE2gV÷CµFÖW"gV÷C²ÒFÖW&æB VæF` ¶6V6²f÷"FÖRÖ÷WBæBFVÆWFP b33c·FÖRÒFÖW&Ffbb33c¶gw7'e÷6ö6¶WG2æfVÆG2gV÷CµFÖW"gV÷C²çfÇVRó bb33c·FÖRfwC²3FVà ¶FVÆWFP euôÆörgV÷C´6öææV7FöâG&÷VBg&öÒgV÷C²fײb33c¶gw7'e÷6ö6¶WG2æfVÆG2gV÷CµW6W"æÖRgV÷C²çfÇVRfײgV÷C²öâ6ö6¶WBgV÷C²fײb33c¶gw7'e÷6ö6¶WG2æfVÆG2gV÷Cµ6ö6¶WBgV÷C²çfÇVR b33c¶gw7'e÷6ö6¶WG2äFVÆWFP b33c¶gw7'e÷6ö6¶WG5ö6÷VçBÓÒ VæF` b33c¶gw7'e÷6ö6¶WG2äÖ÷fTæW@ tVæ@ VæF`¦VæFgVæ0 And of course you just need a while loop calling FWP_TCP_Check() Edited August 8, 2007 by Hostage Link to comment Share on other sites More sharing options...
JohnBailey Posted August 8, 2007 Share Posted August 8, 2007 As to not high-jack this thread, I'm posting my question in regards to Hostage at http://www.autoitscript.com/forum/index.php?showtopic=50956Thanks Hostage. I've got questions though - http://www.autoitscript.com/forum/index.php?showtopic=50956 A decision is a powerful thing 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