Glyph Posted August 6, 2008 Share Posted August 6, 2008 Case $msg = $savesets GUICtrlSetState($savesets,$gui_disable) _GUICtrlStatusBar_SetText($hStatus, "Busy...") Sleep(1000) If GUICtrlRead($comport) = IniRead("untitled.db", "Server", "Port", "63336") Then ;do nothing Else $Port = GUICtrlRead($comport) TCPShutdown() $MainSocket = TCPStartServer($Port, $MaxConnection) _GUICtrlStatusBar_SetText($hStatus, "Port: " & $Port, 1) _GUICtrlStatusBar_SetText($hStatus, "Ready") IniWrite("untitled.db", "Server", "Port", GUICtrlRead($comport)) GUICtrlSetData($serverport,GUICtrlRead($comport)) EndIf if the port changed and you hit savesets then it will shut down tcp and change the port to a new one and start listening o nthat port. problem is, it works and all when you switch to a new port, but if you switch back to the original port, it won't work. i also tested this, i changed ports then tried connecting to the last port on client and it connected, meaning the ports still open. so how do i close the tcp port?? TCPShutdown() isn't working. tolle indicium Link to comment Share on other sites More sharing options...
ptrex Posted August 6, 2008 Share Posted August 6, 2008 @ Try to analyze your problem using the "Netstat -an" command. See if the previous port is not still in use ? Changing a port might not be the same as closing it ?! 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...
Glyph Posted August 6, 2008 Author Share Posted August 6, 2008 (edited) @Try to analyze your problem using the "Netstat -an" command.See if the previous port is not still in use ?Changing a port might not be the same as closing it ?!regards,ptrexthanks for helping,already tried a netstat -n -bno connections open.i figured a tcpshutdown() would clear all of the tcp connections or ports that were open?I do a tcpshutdown, then i reopen the tcp connection on a new port, with a function.Is there a specific way to close the port?? Edited August 6, 2008 by BackStabbed tolle indicium Link to comment Share on other sites More sharing options...
ptrex Posted August 6, 2008 Share Posted August 6, 2008 @BackStabbed If the port is not listed anymore it should be free and released. Try look afterwards again to see of the application or script is listed as listening to that port. If not than the TCPStart did not register properly. First of all you need to analyse. Wether it is a Port conflict or wether it is a TCPStart problem. 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...
Glyph Posted August 6, 2008 Author Share Posted August 6, 2008 No connections relating to the application after running, after connecting to the server there is. But basically, i run the program test the port, it works. then i change ports, still works on the new port, but if i change it yet again to the original port, it fails to open a connection. but the client can still connect to that port, but its not connecting to the server after that.... it's like it's connecting to nothing... heres the tcp codes. (note: i did try debugging this, but i can't figure anything out. i just dont see anything wrong with this...) expandcollapse popupGlobal $Port = IniRead("untitled.db","Server","Port","63336") Global $MainSocket = TCPStartServer($Port, $MaxConc) If @error <> 0 Then Exit MsgBox(16, "Error", "Server unable to initialize.") Case $msg = $savesets GUICtrlSetState($savesets,$gui_disable) _GUICtrlStatusBar_SetText($hStatus, "Busy...") Sleep(1000) If GUICtrlRead($comport) = IniRead("untitled.db", "Server", "Port", "63336") Then ;do nothing Else $Port = GUICtrlRead($comport) TCPShutdown() $MainSocket = TCPStartServer($Port, $MaxConnection) _GUICtrlStatusBar_SetText($hStatus, "Port: " & $Port, 1) _GUICtrlStatusBar_SetText($hStatus, "Ready") IniWrite("untitled.db", "Server", "Port", GUICtrlRead($comport)) GUICtrlSetData($serverport,GUICtrlRead($comport)) EndIf IniWrite("untitled.db", "Server", "Password", GUICtrlRead($serverpass)) If BitAND(GUICtrlRead($btips), $GUI_CHECKED) = $GUI_CHECKED Then IniWrite("untitled.db", "Server", "BTips", "1") Else IniWrite("untitled.db", "Server", "BTips", "0") EndIf _GUICtrlStatusBar_SetText($hStatus, "Ready") GUICtrlSetState($savesets,$gui_enable) MsgBox(0,"Untitled "&$ver,"Settings have been saved!") Func TCPStartServer($Port, $MaxConnect = 1) Local $Socket $Socket = TCPStartup() Select Case $Socket = 0 SetError(@error) Return -1 EndSelect $Socket = TCPListen(@IPAddress1, $Port, $MaxConnect) Select Case $Socket = -1 SetError(@error) Return 0 EndSelect SetError(0) Return $Socket EndFunc ;==>TCPStartServer Port may not be changed back to a previous port e.g. Changed to port 65 from 63336 then again to port 58. You will not be able to use port 65 63336 or 58 over again, if you decide to change. Must be a new port each time. tolle indicium 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