Jump to content
Sign in to follow this  
Aro2220

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

Recommended Posts

Aro2220

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

Share this post


Link to post
Share on other sites
Kip

Why?

God damnit, READ!

First post of my UDF:

You can't create a server and a client in the same script.

And even on the last page of that topic:

When are people going to learn to read?

My first post clearly states, in a very nice underlined font, that:

Share this post


Link to post
Share on other sites
Aro2220

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

Share this post


Link to post
Share on other sites
Kip

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

Share this post


Link to post
Share on other sites
darkjohn20

If you really care that much, make 2 scripts. One will be the client, one will be the server, and have them communicate to each other through something such as a hidden window.

Share this post


Link to post
Share on other sites
storme

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

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  

×