Jump to content

Why can't I create TCP Clients and Servers at the same time?


Recommended Posts

I'm trying to send/receive TCP messages between two of my computers:

#include "TCP.au3"
Global $sMessage = "----"
Global $random = 0

Func Communicate($comm) 
    $sMessage = $comm
    $hClient = _TCP_Client_Create("192.168.0.100", 88)
    _TCP_RegisterEvent($hClient, $TCP_SEND, "SendIt")
EndFunc

Func SendIt($hSocket, $iError)
        _TCP_Send($hSocket, $sMessage)
EndFunc

Func Received($hSocket, $sReceived, $iError)
    ToolTip("SERVER: We recieved this: "& $sReceived, 10, 10)
    $sGetMsg = $sReceived
EndFunc

This successfully sends messages.

;$hServer = _TCP_Server_Create($myport)
;_TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Received")
Communicate("blah")

This successfully receives messages.

$hServer = _TCP_Server_Create($myport)
_TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Received")
;Communicate("blah")

This neither sends nor receives messages.

$hServer = _TCP_Server_Create($myport)
_TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Received")
Communicate("blah")

Why?TCP.au3

Edited by Aro2220
Link to comment
Share on other sites

God damnit, READ!

First post of my UDF:

And even on the last page of that topic:

Is there a workaround?

Sometimes messages do not go through and it goofs up my script. I wanted to have error checking so I could wait until the message was received.

I see that I can not but do not understand why I can not. What you are telling me is that, "you can't because you can't."

Edited by Aro2220
Link to comment
Share on other sites

Is there a workaround?

Sometimes messages do not go through and it goofs up my script. I wanted to have error checking so I could wait until the message was received.

I see that I can not but do not understand why I can not. What you are telling me is that, "you can't because you can't."

AutoIt limitations

Link to comment
Share on other sites

Is there a workaround?

Sometimes messages do not go through and it goofs up my script. I wanted to have error checking so I could wait until the message was received.

I see that I can not but do not understand why I can not. What you are telling me is that, "you can't because you can't."

If you can designate one of the computers as server then you just set up a normal client-server connection and pass messages back and forth that way. The example scripts on Kips thread pass messages back and forth.

If you can't designate a server then 2 programs (1 client, 1 server) is the only alternative I can suggest at the moment.

Good Luck!

Edited by storme
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...