Sign in to follow this  
Followers 0
theguy0000

Server unable to initialize

10 posts in this topic

I run the attached script (or rather, my friend runs it, as I am behind a router it will not work for me anyway), and get "Server unable to initialize". I have no idea what is wrong.

This is AutoIt Smith's remote server beta. Well, kind of. I had the server, added stuff, deleted stuff, and changed stuff to suit my needs.

What am I doing wrong?


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I run the attached script (or rather, my friend runs it, as I am behind a router it will not work for me anyway), and get "Server unable to initialize". I have no idea what is wrong.

This is AutoIt Smith's remote server beta. Well, kind of. I had the server, added stuff, deleted stuff, and changed stuff to suit my needs.

What am I doing wrong?

I would say that either the script is already running or there is another application already running on that port. Auto IT Smiths server code works perfectly out of the Box

you can use it behind a router if you set up port forwarding correctly

Edit.. that will teach me to read it properly, you've edited it.. does the original script run, could still be the port, your reading it from the registry are you still using 8000.

Edited by ChrisL

Share this post


Link to post
Share on other sites

Could also be that @IPAddress1 is seen by the PC as 127.0.0.1 you could try @IPAddress2 or put a message box up to see what the IP and port numbers are. That error happens at the point where it can't open a port so its likely to be something to do with IP's or Ports I think

Share this post


Link to post
Share on other sites

the port in the registry is 44844

@IPAddress1 returns 70.173.62.34


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

The only problem would be if you have the script running already because it does not alert at initial run, and that your computer will not allow TCP Services. If it returns -1 Then you just cannot run TCP Services from AutoIt, if it returns 0 then that port is already in use or AutoIt is already using that port.

Share this post


Link to post
Share on other sites

it returns 0 when i use 44844 but its successfull when i use 8000...

;CWM SERVER: VERSION 0.0.1:PRE-ALPHA

$CWMdir = RegRead ("HKCU\Software\CWMessenger", "CWMdir")
If $CWMdir = "" Then
    MsgBox (16, "CodeWiz Messenger", "Error: Could not read CWMdir from registry HKEY_CURRENT_USER\Software\CWMessenger")
    Exit
EndIf
#cs
$Port = Int(RegRead ("HKCU\Software\CWMessenger\Server", "DefPort"))
If $Port = "" Then
    MsgBox (16, "CodeWiz Messenger", "Error: Could not read DefPort from registry HKEY_CURRENT_USER\Software\CWMessenger")
    Exit
EndIf
#ce
$Port = 44844
Global $MaxConc = 100
Global $MainSocket = TCPStartServer($Port, $MaxConc)
If @error <> 0 Then Exit MsgBox(16, "Error", "Server unable to initialize."&@CRLF&@CRLF&"DEBUG---ERROR-CODE-"&@error&@CRLF&"DEBUG---RETURN-VALUE-"&$MainSocket)
MsgBox (64, "CodeWiz Messenger", "Server started successfully at "&@IPAddress1)
Global Const $MaxLength = 512
Global $ConnectedSocket[$MaxConc]
Global $CurrentSocket = 0
Local $Track = 0
Global Const $MaxConnection = ($MaxConc - 1)
For $Track = 0 To $MaxConnection Step 1
    $ConnectedSocket[$Track] = -1
Next
While 1
    $ConnectedSocket[$CurrentSocket] = TCPAccept($MainSocket)
    If $ConnectedSocket[$CurrentSocket] <> - 1 Then
        $CurrentSocket = SocketSearch()
    EndIf
    $Track = 0
    For $Track = 0 To $MaxConnection Step 1
        If $ConnectedSocket[$Track] <> - 1 Then
            $Data = TCPRecv($ConnectedSocket[$Track], $MaxLength)
            If $Data <> "" Then
                CWM_msg_interp($Data)
            EndIf
        EndIf
    Next
WEnd

;----------------
#region functions---------------------------------------------------------------------------------------------------------------------
;----------------

Func SocketSearch()
    Local $Track = 0
    For $Track = 0 To $MaxConnection Step 1
        If $ConnectedSocket[$Track] = -1 Then
            Return $Track
        Else
       ; Socket In Use
        EndIf
    Next
EndFunc ;==>SocketSearch
Func TCPSendMessageAll($ConnectionLimit, $Data)
    Local $Track = 0
    For $Track = 0 To $ConnectionLimit Step 1
        If $ConnectedSocket[$Track] <> - 1 Then TCPSend($ConnectedSocket[$Track], $Data)
    Next
EndFunc ;==>TCPSendMessageAll
Func TCPStartServer($Port, $MaxConnect = 1)
    Local $Socket
    $Socket = TCPStartup()
    If $Socket = 0 Then
        SetError (@error)
        return -1
    EndIf
    $Socket = TCPListen(@IPAddress1, $Port, $MaxConnect)
    If $Socket = -1 Then
        SetError(@error)
        Return 0
    EndIf
    SetError(0)
    Return $Socket
EndFunc ;==>TCPStartServer

;------------------------------------------

Func CWM_msg_interp ($inputmsg)
    $msg_split = StringSplit ($inputmsg, ",")
    If $msg_split[0] > 3 Then
        For $i=4 To $msg_split[0]
            $msg_split[3] &= $msg_split[$i]
        Next
    EndIf
    $IP = $msg_split[1]
    $Action = $msg_split[2]
    $info = $msg_split[3]
    $temp_conn = TCPConnect ($IP, $Port)
    Switch $Action
        Case "Register"
            $register_info = StringSplit ($info, " ")
            If IniRead ( $CWMdir&"\info.ini", "registered_users", $register_info[1], "" ) <> "" Then
                TCPSend ($temp_conn, @IPAddress1 & ",CannotRegister,Registration was unsuccessfull. The specified username already exists.")
            Else
                If IniWrite ($CWMdir&"\info.ini", "registered_users", $register_info[1], $register_info[2]) = 0 Then
                    TCPSend ($temp_conn, @IPAddress1 & ",CannotRegister,Registration was unsuccessfull. The server info file is mode R. please notify theguy0000@gmail.com.")
                    MsgBox ( 48, "CodeWiz Messenger", $IP & " tried to register with username "&$register_info[1]&" and password "&$register_info[2]&", but was unsuccessful because the info.ini file is Read-Only.")
                EndIf
            EndIf
    EndSwitch
EndFunc

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Then that means either:

1. The program is ALREADY running

2. The port is in use by another program

3. Invalid port

4. Invalid IP (Usually Not The Case)

Edited by AutoIt Smith

Share this post


Link to post
Share on other sites

Then that means either:

1. The program is ALREADY running

2. The port is in use by another program

3. Invalid port

4. Invalid IP (Usually Not The Case)

oops.

choice 1 is the answer ;)

thanks

Matt :lmao:


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

No problem.

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