Jump to content
Sign in to follow this  
dromenox

TCP Client Problem

Recommended Posts

dromenox
I want to make a client-server system for use in an application, but is not working properly. When the server is not running, the client displays the tooltip with error message, but when the server is running nothing happens! Neither the tooltip displaying success message appears! 
 
 
Client:
 
#include "TCP.au3"

Global $hClient = _TCP_Client_Create(@IPAddress1, 50000)
global $Connected = False

_TCP_RegisterEvent($hClient, $TCP_RECEIVE, "Recv")
_TCP_RegisterEvent($hClient, $TCP_CONNECT, "Connected")
_TCP_RegisterEvent($hClient, $TCP_DISCONNECT, "Disconnected")

While 1
WEnd

Func Recv($hSocket, $sReceived, $iError)
EndFunc

Func Connected($hSocket, $iError)
   If $iError Then
      ToolTip("CLIENT: Cannot connect", 10, 10)
   Else
      ToolTip("CLIENT: Connected", 10, 10)
      $Connected = True
   EndIf
EndFunc

Func Disconnected($hSocket, $iError)
   ToolTip("CLIENT: Disconnected", 10, 10)
   $Connected = False
EndFunc

Server:

#include "TCP.au3"

Global $hServer = _TCP_Server_Create(50000)

_TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient")
_TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnected")
_TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Recv")

Func NewClient($hSocket, $iError)
   ToolTip("SERVER: New Client", 100, 100)
EndFunc

Func Disconnected($hSocket, $iError)
   ToolTip("SERVER: Disconnected Client", 100, 100)
EndFunc

Func Recv($hSocket, $sReceived, $iError)
   ToolTip("SERVER: Received: " & $sReceived, 100, 100)
EndFunc

While 1
WEnd
Edited by dromenox

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  

×