inet Posted July 2, 2008 Share Posted July 2, 2008 Too bad, Are you planning on making such a function? Link to comment Share on other sites More sharing options...
Kip Posted July 2, 2008 Author Share Posted July 2, 2008 (edited) Oh, sorry. I was reading your post wrong. You DO can register a disconnect event. _TCP_RegisterEvent($TCP_DISCONNECT, "Function") Func Function($iError) Msgbox(0,"Server or Client","(Client: We lost our connection to the server) or (Server: A client has closed his connection)") EndFunc Edited July 2, 2008 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
inet Posted July 2, 2008 Share Posted July 2, 2008 Thanks for the help Link to comment Share on other sites More sharing options...
Kip Posted July 2, 2008 Author Share Posted July 2, 2008 You're welcome MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
ptrex Posted July 2, 2008 Share Posted July 2, 2008 @Kip Excuseer !! Ecents and ASyncSocket included ?! If that is the case, than you are the man Regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Kip Posted July 2, 2008 Author Share Posted July 2, 2008 (edited) Ecents and ASyncSocket included ?!Yes. Edited July 2, 2008 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Xand3r Posted July 2, 2008 Share Posted July 2, 2008 no offence but i think that alek's ideea(to pass a client number instead of the socket) is easyer and better Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
laurent68 Posted July 2, 2008 Share Posted July 2, 2008 Ok, new UDF uploaded. It's not much simpler. I hope you can still understand the new version.This is really event driven. Using the UDF created by Zatorg.New function names, so you'll have to rewrite some stuff.many thanks for you UDF, very usefull.Unfotunately, i understand sample Server.au3 and Client.au3 but with your new version, there is new name and new function, and i not understand how to use them.you don't write so much comment in your code ;-)I'm a bit lost with _TCP_RegisterEvent for examplevery big thanks again for your jobLaurent Link to comment Share on other sites More sharing options...
Kip Posted July 2, 2008 Author Share Posted July 2, 2008 (edited) Unfotunately, i understand sample Server.au3 and Client.au3 but with your new version, there is new name and new function, and i not understand how to use them.you don't write so much comment in your code ;-)I'm a bit lost with _TCP_RegisterEvent for examplevery big thanks again for your jobLaurentI'll try to add comments again.no offence but i think that alek's ideea(to pass a client number instead of the socket) is easyer and betterI don't see the reason why...?Edit: 900th post Edited July 2, 2008 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Kip Posted July 2, 2008 Author Share Posted July 2, 2008 I added comments to the examples. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
laurent68 Posted July 2, 2008 Share Posted July 2, 2008 I added comments to the examples.ok thanks, so i have make a mistake. i have look a example in download file in Pages 3, not in YOUR example in Page 1.In page1 it's enough clear one more time, many thanks you save me many days with your code Link to comment Share on other sites More sharing options...
Kip Posted July 3, 2008 Author Share Posted July 3, 2008 (edited) ok thanks, so i have make a mistake.You muttley !*#@! Edited July 3, 2008 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
ludocus Posted July 5, 2008 Share Posted July 5, 2008 yeh this is pretty nice..But has problems..Tip:Why dont you make a real udf.. (Have a look here: http://www.autoitscript.com/autoit3/udfs/UDF_Standards.htm)Because you have the functions but it is not clear what the exact error or succes returns are.. and more..it also would be handy to see what every function does... (Thats what a good udf should have..)And then my qeustion..I was trying to make a simple chat system..here is my server:#include "TCP.au3" #include <INet.au3> _TCP_Server_Create(88); A server. Tadaa! _TCP_RegisterEvent($TCP_NEWCLIENT, "NewClient"); Whooooo! Now, this function (NewClient) get's called when a new client connects to the server. _TCP_RegisterEvent($TCP_DISCONNECT, "Disconnect"); And this,... this will get called when a client disconnects. _TCP_RegisterEvent($TCP_RECEIVE, "Received") While 1 WEnd Func NewClient($iError); Yo, check this out! It's a $iError parameter! (In case you didn't noticed: It's in every function) ;_TCP_Server_Send('||| CONN:') EndFunc Func Received($iError, $sReceived) _TCP_Server_Send($sReceived) EndFunc Func Disconnect($iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P EndFuncAnd here is my client:expandcollapse popup#include "TCP.au3" #include <INet.au3> #include <ButtonConstants.au3> #include <GUIConstants.au3> #include <EditConstants.au3> _TCP_Client_Create(88, @IPAddress1); Create the client. Which will connect to the local ip address on port 88 _TCP_RegisterEvent($TCP_RECEIVE, "Received"); Function "Received" will get called when something is received _TCP_RegisterEvent($TCP_CONNECT, "Connected"); And func "Connected" will get called when the client is connected. ;_TCP_RegisterEvent($TCP_DISCONNECT, "Disconnected"); And "Disconnected" will get called when the server disconnects us, or when the connection is lost. $username='ludocus' $Form1 = GUICreate("Begin of chat", 633, 447, 190, 123) $Button1 = GUICtrlCreateButton("Send", 560, 16, 57, 25, $BS_DEFPUSHBUTTON) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $Input1 = GUICtrlCreateInput("", 392, 16, 161, 24) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $List1 = GUICtrlCreateList("", 392, 80, 217, 344) $Label1 = GUICtrlCreateLabel("Users:", 392, 56, 34, 17) $Edit1 = GUICtrlCreateEdit("", 8, 8, 377, 433) GUICtrlSetFont(-1, 10, 800, 0, "Arial") GUISetState(@SW_SHOW) _TCP_Client_Send($username&' has logged in') While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _TCP_Client_Send(GUICtrlRead($Input1)) EndSwitch WEnd Func Connected($iError); We registered this (you see?), When we're connected (or not) this function will be called. If not $iError Then; If there is no error... ToolTip("CLIENT: Connected!",10,10); ... we're connected. Else; ,else... ToolTip("CLIENT: Could not connect. Are you sure the server is running?",10,10); ... we aren't. EndIf EndFunc Func Received($iError, $sReceived) If StringLeft($sReceived, 9) = '||| CONN:' Then $nString = StringReplace($sReceived, '||| CONN:', '') $sReceived = $nString&' has connected..' EndIf $tkst = GUICtrlRead($Edit1) if $tkst = '' then GUICtrlSetData($Edit1, $sReceived) Else GUICtrlSetData($Edit1, $tkst&@CRLF&$sReceived) EndIf EndFuncOk you said in your 1st post: No more messing with multiple clients..Well, Your thingie can only support 1 client.. Or am I making mistakes?cause when I open multiple windows of my client and 1 server.. It only supports its own client..(For example: I run the server.. I run the client 2 times.. I send at the first client: Hello Client2. But then I look at the second client and there is no line of text added saying: hello) Link to comment Share on other sites More sharing options...
MerkurAlex Posted July 6, 2008 Share Posted July 6, 2008 Great job kip i had already made my multi user server for my ORPG but since this is event driven and as such more powerful(im not going with it cause of the simplicity) im going to start using it instead thanks again! @ludocus That "MAKE A REAL UDF" statement is kinda true but rude at the same time im sure someone that needs to can figure out very easily what error when't on and as for your code the server is receiving it but not sending to the other client(s) it looks like its sending back to the received client try going through the list of connected clients if its not the one it received from send it to that one so all clients but the one that sent it receive the same thing. [quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote] Link to comment Share on other sites More sharing options...
Kip Posted July 6, 2008 Author Share Posted July 6, 2008 Use _TCP_Server_Broadcast instead of _TCP_Server_Send MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
ludocus Posted July 6, 2008 Share Posted July 6, 2008 thnx alot!! Link to comment Share on other sites More sharing options...
ludocus Posted July 7, 2008 Share Posted July 7, 2008 Ok so I went on with my script and now I have a sweet chat system and computer control in one.. look: client.au3 Server.au3 so.. but the thing is it only works at @IPAddress1 so only local.. And when I try using _GetIP() it doesn't work.. does somebody know how to make the server listen to the whole world? and that the client connects to my ip adress not only @IPAddress1..? Please I really need help with this.. Link to comment Share on other sites More sharing options...
Alek Posted July 7, 2008 Share Posted July 7, 2008 Ok so I went on with my script and now I have a sweet chat system and computer control in one.. look: client.au3 Server.au3 so.. but the thing is it only works at @IPAddress1 so only local.. And when I try using _GetIP() it doesn't work.. does somebody know how to make the server listen to the whole world? and that the client connects to my ip adress not only @IPAddress1..? Please I really need help with this.. use 0.0.0.0 [font="Impact"]Never fear, I is here.[/font] Link to comment Share on other sites More sharing options...
ludocus Posted July 7, 2008 Share Posted July 7, 2008 that doesn't work either.. I think I have to set up a static ip.. Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted July 7, 2008 Share Posted July 7, 2008 Alek is correct, but you may also have to fix whatever firewall you have to port forward to the proper computer. 0.0.0.0 is the INADDR_ANY value, which tells the networking code to listen for packets destined for any address that your program happens to get. Using a specific IP will limit what address the packets can be destined to (so, if you use your public IP there, no one on the lan can talk to it, and, as you've seen, if you use your lan IP, no one on the outside can talk to it either). As far as static vs dynamic IP's, you can use a service like DynDNS, and just point people/clients at your dns name. It's a good thing to do usually any way, for it makes updating your IP a lot easier, and your clients can stay the exact same no matter how many times your IP changes. 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