Jump to content

Recommended Posts

Posted (edited)

Help FIle not working for me (Win8.1 X64)

it opens, and i get a tree with all functions, but no text and the name is still TCPMaker, which might have been a working title

post-5062-0-99696300-1429379591_thumb.jp

Edited by Allow2010
Posted
  On 4/18/2015 at 5:51 PM, Allow2010 said:

Help FIle not working for me (Win8.1 X64)

it opens, and i get a tree with all functions, but no text and the name is still TCPMaker, which might have been a working title

 

Hi, thanks for your reply!

That looks strange... But I've uploaded a HTML version on the original post. Could you test it, please?

My stuff

  Reveal hidden contents

 

Posted (edited)

html version works in firefox but some pictures are missing (icons in the tree) see screenshot, and it ssems as if some info is missing...

Does not work in InternetExplorer.

post-5062-0-99519500-1429380730_thumb.jp

Edited by Allow2010
Posted
  On 4/18/2015 at 6:10 PM, Allow2010 said:

html version works in firefox but some pictures are missing (icons in the tree) see screenshot, and it ssems as if some info is missing...

Does not work in InternetExplorer.

 

As well as some of us say, sometimes documenting is harder than programming :blink:

HelpMaker really 'forgot' to put a folder with the graphics used on the page. Luckly I've found this folder on Google. So here is the updated version:

TCPServer HTML Help.rar

My stuff

  Reveal hidden contents

 

Posted

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

@Jefrey

Again Thank you for your UDF.

For me there are still symbols missing in the new version oft html help.

If you find a way, i (personally, maybe others see it different) would prefer a working chm file.

Also i would like to have headers for every function in the code explaining parameters, returncodes and what the function does if you are willing to write them...most functions and udfs have them...its often easier to stay in the code while learning...

Posted (edited)

Jefrey! Excellent job and thank you for sharing!

I have a dumb question, sorry.

If _TCPServer_Start is only accepting the "port", is it possible to use a different IP Address another way? For example, exposing the server to the internet and thus needing to use the external IP address.

By the way, the help file itself works perfectly!

Thank you again!

  On 4/18/2015 at 5:39 PM, Jefrey said:

Hi guys/girls!

I'm gonna share this UDF I made today.

It allows you to easily create TCP servers and set actions depending on three events: OnConnect, OnDisconnect and OnReceive.

It is also multi client (you can set the clients limit) and you can also bind a Console-based executable to the socket (similar to -e parameter in NetCat). This feature is useful if you want to use some Console UDF to create your TCP server and don't want to mix it with the TCP functions. Also, as it runs on background just firing events, it won't pause your script while listening/receiving, so you can do anything else (stop and restart the server, allow the user to click buttons or just wait on an infinite loop) that your callbacks will be called once the event is fired.

It's also very easy to use. See this examples:

The limit is your imagination? Well, no sure. We have this limit:

  • You can't create more than one server with this UDF in the same script. However, you can pause and resume (read 'stop and start again') your server at any time in your script, without having to reset the server settings. And of course you can have many clients (or just one, it's your choice!) in the same server.

Functions list:

_TCPServer_Start

_TCPServer_Stop

_TCPServer_Close

_TCPServer_Send

_TCPServer_Broadcast

_TCPServer_SetParam

_TCPServer_BindAppToSocket

_TCPServer_SendToBound

_TCPServer_UnBindAppToSocket

_TCPServer_GetMaxClients

_TCPServer_IsServerActive

_TCPServer_ListClients

_TCPServer_OnConnect

_TCPServer_OnDisconnect

_TCPServer_OnReceive

_TCPServer_SetMaxClients

_TCPServer_DebugMode

_TCPServer_AutoTrim

_TCPServer_SocketToIP

_TCPServer_SocketToConnID

_TCPServer_ConnIDToSocket

 

Help file and more examples included!

Latest version: 1.0

attachicon.gifTCPServer UDF.zip

Note: if the CHM help file does not work for you, use the HTML version below and run index.hta or index.htm.

HTML help.rar

Edited by coffeeturtle
Posted

  On 4/20/2015 at 4:05 PM, coffeeturtle said:

By the way, the help file itself works perfectly!

 

Hmm, i tried again on win8 and win7 and for me the helpfile does not work...only the tree comes up, but no text on the right side...

Posted
  On 4/21/2015 at 12:26 PM, Allow2010 said:

Hmm, i tried again on win8 and win7 and for me the helpfile does not work...only the tree comes up, but no text on the right side...

 

Sorry to ask you this basic question, but do you have all of the files unzipped to one folder? Launching Help.chm from within that folder with all of the files should be good. Otherwise, index.hta would probably be the best option.

Posted
  On 4/18/2015 at 5:51 PM, Allow2010 said:

Help FIle not working for me (Win8.1 X64)

it opens, and i get a tree with all functions, but no text and the name is still TCPMaker, which might have been a working title

 

Did you unzip Zip archive , or you just click on downloaded zip file which as I suspect opens in Explorer, and did you open this CHM directly from Zip archive ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Thanks for your idea, i rechecked and found the problem:

I unpacked to my NAS and so i started the chm from an undc path myservermysharefileshelp.chm

Never had this with precompiled chm files...maybe this is because you reference some files from inside the chm and they can not be found on und path.

This seems to be a problem...from a alocal folder the chm works fine. Sorry for causing troubles...

Posted (edited)

This is IExplorer security issue.

Edit: 

This is related to: security zones

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Func __TCPServer_Accept()
    If $__TCPServer_Sockets[0] >= $_TCPServer_MaxClients Then
        ;Return
    EndIf
    $accept = TCPAccept($__TCPServer_MainSocket)
    If $accept = -1 Then Return
    For $i = 1 To $_TCPServer_MaxClients
        If $__TCPServer_Sockets[$i] = 0 Then ; socket is empty
            $__TCPServer_Sockets[$i] = $accept
            $__TCPServer_Sockets[0] += 1
            $__TCPServer_SocketCache[$i][0] = $accept
            $__TCPServer_SocketCache[$i][1] = _TCPServer_SocketToIP($accept)
            If $_TCPServer_DebugMode Then __TCPServer_Log("Client " & _TCPServer_SocketToIP($accept) & " connected to socket " & $accept)
            Call($_TCPServer_OnConnectCallback, $__TCPServer_Sockets[$i], _TCPServer_SocketToIP($__TCPServer_Sockets[$i]))
            Return 0
        EndIf
    Next
EndFunc   ;==>__TCPServer_Accept

i think the ;retrun must be uncommented...else the maxlients limit is ignored...?!

Posted (edited)

Hi, sflr, I've been busy with some things in college. Good to see that your problem was solved,  @Allow2010! Thanks for those who helped! As soon as I get some time again, I'll document it on the UDF itself (each function).

@coffeeturtle,

  Quote

If _TCPServer_Start is only accepting the "port", is it possible to use a different IP Address another way? For example, exposing the server to the internet and thus needing to use the external IP address.

Yes! By default, _TCPServer_Start will listen on 0.0.0.0, which, theoretically, will listen in any interface. But if you want to listen in other interface, like the external IP, just pass it as second (optional) parameter:

#include <Inet.au3>
#include "TCPServer.au3"

_TCPServer_Start(8081, _GetIP())

; or 

_TCPServer_Start(8082, '127.0.0.1')

_TCPServer_Start(8083, 'mydomain.no-ip.com')

Of course there are other questions to consider, like if the port is visible to the internet (open and redirected to the host in the router).

@Allow2010,

  Quote

 think the ;retrun must be uncommented...else the maxlients limit is ignored...?!

Damn... how could it pass in front of me... I commented it for debugging while developing it. It must be uncommented, you're right. I must upload the patched version ASAP to the original post. Thanks for pointing it!

Edit: UDF updated on the original post!

Edited by Jefrey

My stuff

  Reveal hidden contents

 

  • 4 years later...
Posted (edited)

@Jefrey Thank you for the excellent work & sharing!

FYI, I'm working on a project that makes a Socket Relay, it receives data from clients (for example, 2 clients) then pass received data to destinations (e.g 3)

I have one question related to the TCPRcv

Func __TCPServer_Recv()
    For $i = 1 To $_TCPServer_MaxClients
        If ($__TCPServer_Sockets[$i] = 0) Then ContinueLoop ;If socket is not exist then move to the next entry

        Dim $sData
        $recv = TCPRecv($__TCPServer_Sockets[$i], 1000000)
        If @error = 10054 Then ; Disconnected by user
            __TCPServer_KillConnection($i)
            ContinueLoop
        EndIf

        If $recv Then
            $sData = $recv
            Do
                $recv = TCPRecv($__TCPServer_Sockets[$i], 1000000)
                $sData &= $recv
            Until $recv = ""
            If $_TCPServer_AutoTrim Then
                $sData = StringStripWS($sData, 1 + 2)
            EndIf
            If $_TCPServer_DebugMode Then __TCPServer_Log("Client " & _TCPServer_SocketToIP($__TCPServer_Sockets[$i]) & " sent " & $sData)
            Call($_TCPServer_OnReceiveCallback, $__TCPServer_Sockets[$i], _TCPServer_SocketToIP($__TCPServer_Sockets[$i]), $sData, $__TCPServer_Pars[$i])
            
        EndIf
    Next
EndFunc   ;==>__TCPServer_Recv

May I ask, after getting data from $recv = TCPRecv($__TCPServer_Sockets[$i], 1000000)

you call another TCPRecv($__TCPServer_Sockets[$i], 1000000) until it has no data.
What does this thing do?
If I remove the Do...Util block, does it has any risk?

Edited by LukeLe
add full function __TCPServer_Recv

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
×
×
  • Create New...