Jump to content
Sign in to follow this  
Kip

TCP UDF, Event driven!

Recommended Posts

Just what i was looking for.

Is there anyway to get the clientid on disconnect? using _TCP_Server_ActiveClient() doesn't produce the active client that disconnected.

Edited by kjcdude

Share this post


Link to post
Share on other sites

Just what i was looking for.

Is there anyway to get the clientid on disconnect? using _TCP_Server_ActiveClient() doesn't produce the active client that disconnected.

I too had this problem. On client disconnect the Disconnect event didnt return a socket (was impossible to tell who had just disconnect) but i found a way to fix this.

Open up your tcp.au3 file in scite and look to lines 370, 371, 372 and you will see this:

$_TCP_ACTIVESOCKET = $hSocket
; Connection closed
Call($_TCP_HSOCKETS[$iSelected][4],$hSocket,$iError)

Basicly the script is wiping the socket before sending it to you. So just swap the lines around so it reads:

; Connection closed
Call($_TCP_HSOCKETS[$iSelected][4],$hSocket,$iError)
$_TCP_ACTIVESOCKET = $hSocket

It should then return the disconnected socket :mellow:

Edited by Marlo

Click here for the best AutoIt help possible.Currently Working on: Autoit RAT

Share this post


Link to post
Share on other sites

$_TCP_ACTIVESOCKET = $hSocket
; Connection closed
Call($_TCP_HSOCKETS[$iSelected][4],$hSocket,$iError)

Basicly the script is wiping the socket before sending it to you. So just swap the lines around so it reads:

; Connection closed
Call($_TCP_HSOCKETS[$iSelected][4],$hSocket,$iError)
$_TCP_ACTIVESOCKET = $hSocket

It should then return the disconnected socket :mellow:

Wish i saw this last night. I built a whole system that logs the ids to an ini file then constantly compares the active ones to the ones stored in the ini file.

Your way is much simpler.

Thanks

Edited by kjcdude

Share this post


Link to post
Share on other sites

Not sure if this is a bug.

I've only been able to produce it within a server side receive.

When a server receives text from a client "Func Received($iError, $sReceived)" and _TCP_Server_ActiveClient() is called within that func recieve, the active client ID will be displayed as HEX instead of a DEC as seen throughout the rest of the script.

I now have a check on all calls for _TCP_Server_ActiveClient() to see if it's a hex or dec and convert it to a dec so that it's uniformed.

Share this post


Link to post
Share on other sites

Not sure if this is a bug.

I've only been able to produce it within a server side receive.

When a server receives text from a client "Func Received($iError, $sReceived)" and _TCP_Server_ActiveClient() is called within that func recieve, the active client ID will be displayed as HEX instead of a DEC as seen throughout the rest of the script.

I now have a check on all calls for _TCP_Server_ActiveClient() to see if it's a hex or dec and convert it to a dec so that it's uniformed.

It'd be nice to see Kip revisit this UDF. It's got a lot of potential, IMHO. But what exactly did you do? Modify the UDF directly?

Share this post


Link to post
Share on other sites

Hey Kip, what's the license you are releasing this under?

I'd like to translate it to another language and use it in a commercial product.

Seeing as the post above is 'none'.

Just give him credit somewhere for the original code.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

It'd be nice to see Kip revisit this UDF. It's got a lot of potential, IMHO. But what exactly did you do? Modify the UDF directly?

I was really lazy and just did it on the server side where i needed it.

Here's the code where it's checked.

$cactive = _TCP_Server_ActiveClient()
         if StringIsDigit($cactive) = 0 Then
            $c1 = StringSplit($cactive, "x")
            $convertedd = Dec($c1[2])
            IniWrite($inifile, "Connections", $convertedd, "Not")
         Else
            IniWrite($inifile, "Connections", _TCP_Server_ActiveClient(), "Not")
         EndIf

Share this post


Link to post
Share on other sites

_TCP_Client_Send() does not seem to work. I have a client and server setup, and the server is waiting for the information sent by the client, but it never seems to arrive to the server.

Why? (I can post script if needed.)

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Yes. I can send from the server to the client. But not the other way around. So I can't tell if the client isn't sending, or the server isn't recieving.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Pop open telnet and connect to your server and see if the server is working.

Well, I can connect from the client. The server returns that the client is connected, and the client responds that it is connected. I'll try the telnet when I get home.

The server is waiting for Received() to be called, then it will report what was received. But it never seems to get called. I'll check the the telnet thing when I get home.

EDIT: I forgot...I'm on vista. I don't have telnet. I did attempt to connect through Firefox. It was able to connect.

If anybody needs the client or server code, I'll be happy to PM it to them.

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Bump. Please help. This issue is pissing me off.

Client does not send to server.

Or server is not receiving.

EDIT: Code removed.

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Hmm, I made some very big mistakes. I think I'll have to rewrite the whole UDF :)

Sorry for that.

Is that a joke, or did I find some error or something? lol.

Do you know why it doesn't seem to work?


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Not a joke.

But I didn't look to the MSDN pages while making it, and I haven't done a lot of testing, so bugs could sneak in very easily.

Alright. Please fix it as soon as possible. :)


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...