Sign in to follow this  
Followers 0
JohnRichard

TCPSend GUI

13 posts in this topic

hi all. i have created a small GUI. is it possible that this GUI can be send by by client by TCPSend? Then if its successfully received, the server will show the GUI received.

thanks.

Share this post


Link to post
Share on other sites



hi all. i have created a small GUI. is it possible that this GUI can be send by by client by TCPSend? Then if its successfully received, the server will show the GUI received.

thanks.

Do you know what mean GUI? How do you want to send a GUI? What purposed?

When the words fail... music speaks

Share this post


Link to post
Share on other sites

No, but there are 3 other ways I think for what you mean.

1) send the .exe via tcp/ip;

2) send a command tot the receiver and allready have the gui in the reciever .exe

3) send all the variables needed to build a gui.

like:

guicreate($title, $width, $height, $left, $top)

and send those variabled via tcp/ip.

Someone please correct me if i'm wrong!!


My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites

Do you know what mean GUI? How do you want to send a GUI? What purposed?

yes i know what is GUI. that is why i am asking if its possible to send it by TCP. it just that i want some information from the client to be send to the receiving server. like IP add and PC name of the client PC to be send by TCP. i am able to send it by TPCSend and server receives it by displaying it in a traytip.

server already has a ready GUI. what i want to happen, when client send info, server receives info then display info with the corresponding values in the GUI. this is where i am stuck. forgive me if i am sounding very confusing.

that is why i am thinking if GUI is in the client, then it will just send the GUI to the server by TCP.

as Triblade said its not possible but there is other way.

Share this post


Link to post
Share on other sites

JohnRichard, if you receive values from the client then you can just display them in the GUI. GUICtrlSetData is the function to set a value in a GUI.

If you're confused about what you are writing, then I recommend writing a document for your program where you explain what is going to happen. Don't try and make silly conclusions like .. sending a GUI over network.

Share this post


Link to post
Share on other sites

No, but there are 3 other ways I think for what you mean.

1) send the .exe via tcp/ip;

2) send a command tot the receiver and allready have the gui in the reciever .exe

3) send all the variables needed to build a gui.

like:

guicreate($title, $width, $height, $left, $top)

and send those variabled via tcp/ip.

Someone please correct me if i'm wrong!!

hi triblade. i already have a ready gui in the server which i am trying now. my gui is just simple. its an INPUT for IP add PC name of client connected. i just can't figured out how will i retreive the IP and PC name of the client to the GUI.

using a traytip i can get these info. but i wanted this to be displayed in the GUI which is in the server.

forgive me if i am sounding like stupid with this.

Share this post


Link to post
Share on other sites

I noticed that you are concerned about the TCP but I wonder if you read anything about it.

You just ask questions and hoping to get an answer and still have not learned how TCP works.

No offense, but I suggest you to read carefully the help file, and then ask questions.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

I noticed that you are concerned about the TCP but I wonder if you read anything about it.

You just ask questions and hoping to get an answer and still have not learned how TCP works.

No offense, but I suggest you to read carefully the help file, and then ask questions.

ok. i 'll try to read and understand as much as i can to better learn from it.

Share this post


Link to post
Share on other sites

A simple example:

SERVER

HotKeySet("{ESC}","Quit")
TCPStartup()
$LISTEN = TCPListen(@IPAddress1,3001)

Do
    $SOCKET = TCPAccept($LISTEN)
    Sleep(25)
Until $SOCKET <> -1

While 1
    $RECV = TCPRecv($SOCKET,512)
    If $RECV <> "" Then
        $SPLIT = StringSplit($RECV,"~")
        If IsArray($SPLIT) Then
            If $SPLIT[0] = 2 Then MsgBox(0,"Info","IP: " & $SPLIT[1] & @CRLF & "Computer: " & $SPLIT[2])
        EndIf
    EndIf
    Sleep(20)
WEnd

Func Quit()
    TCPShutdown()
    Exit
EndFunc

CLIENT

TCPStartup()
$CLIENT = TCPConnect(@IPAddress1,3001)
If $CLIENT = -1 Then MsgBox(0,"","ERROR")
TCPSend($CLIENT,@IPAddress1 & "~" & @ComputerName)
Sleep(5000)
TCPShutdown()

Hope is what you want. I think it's easy to understand what I do.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

hi manadar. thanks for that point. that's why i asked if this is possible.

ok. here is what i want to happen. when client succefully connects to server it will send this info. (IP, PC name and user logged on to the PC)

in the server, there is a gui waiting for the info to be send by the client. on this part i don't know how to retreive each values to be set in the GUI.

i have tried on the server, to display this info by Traytip and it is successfully showing the info but in the GUI part its not.

TCP Send client

TCPSend($socket, "   PC Name : " & @ComputerName &@CRLF & "IP Address : " & @IPAddress1 &@CRLF & "   User ID : " & @UserName)

TCP Receive Server

While 1
    $CONNECTED_SOCKET[$CURRENT_SOCKET] = TCPAccept($TCP_SERVER)
    If $CONNECTED_SOCKET[$CURRENT_SOCKET] <> -1 Then
        $CURRENT_SOCKET += 1
    EndIf
    For $INDEX = 0 To 15
        $RECV = TCPRecv($CONNECTED_SOCKET[$INDEX],512)
        If $RECV <> "" Then         
                                     Info()
                                  EndIf
    Wend

copy of my GUI is this...

Func Info()
Opt('GUIOnEventMode', 0)
$Form1 = GUICreate("Information", 333, 146, -1, -1)
$Input1 = GUICtrlCreateInput($RECV), 11), 150, 20, 177, 28, $ES_READONLY)
GUICtrlSetFont($Input1, 12, 800, 0, "Verdana")
GUICtrlSetResizing($Input1, $GUI_DOCKAUTO)
$Input2 = GUICtrlCreateInput($RECV), 150, 61, 177, 28, $ES_READONLY)
GUICtrlSetFont($Input2, 12, 800, 0, "Verdana")
$Label1 = GUICtrlCreateLabel("PC Name :", 5, 21, 143, 24)
GUICtrlSetFont($Label1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("IP Address :", 45, 62, 102, 24)
GUICtrlSetFont($Label2, 12, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("OK", 75, 110, 90, 26, 0)
GUICtrlSetFont($Button1, 10, 800, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("Exit", 180, 110, 90, 26, 0)
GUICtrlSetFont($Button2, 10, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)   

            While 1
                $msg = GUIGetMsg()
                    Select
                        Case $msg = $GUI_EVENT_CLOSE or $msg = $Button2 
                            Quit()
                        Case $msg = $Button1
                    ;GUISetState(@SW_MINIMIZE)
                                                    
                    EndSelect
            WEnd
    EndFunc
The problem lies in variable scope. Rather pass the variable $RECV to function Info, so you can be sure the info is getting there. Then it makes sense to use a function too, and not only for readability.

Something along the lines of:

While 1
    $CONNECTED_SOCKET[$CURRENT_SOCKET] = TCPAccept($TCP_SERVER)
    If $CONNECTED_SOCKET[$CURRENT_SOCKET] <> -1 Then
        $CURRENT_SOCKET += 1
    EndIf
    For $INDEX = 0 To 15
        $RECV = TCPRecv($CONNECTED_SOCKET[$INDEX],512)
        If $RECV <> "" Then         
                                     Info($RECV)
                                  EndIf
    Wend

Func Info($sData)
Opt('GUIOnEventMode', 0)
$Form1 = GUICreate("Information", 333, 146, -1, -1)
$Input1 = GUICtrlCreateInput($sData), 11), 150, 20, 177, 28, $ES_READONLY)
GUICtrlSetFont($Input1, 12, 800, 0, "Verdana")
GUICtrlSetResizing($Input1, $GUI_DOCKAUTO)
$Input2 = GUICtrlCreateInput($sData), 150, 61, 177, 28, $ES_READONLY)
GUICtrlSetFont($Input2, 12, 800, 0, "Verdana")
$Label1 = GUICtrlCreateLabel("PC Name :", 5, 21, 143, 24)
GUICtrlSetFont($Label1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("IP Address :", 45, 62, 102, 24)
GUICtrlSetFont($Label2, 12, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("OK", 75, 110, 90, 26, 0)
GUICtrlSetFont($Button1, 10, 800, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("Exit", 180, 110, 90, 26, 0)
GUICtrlSetFont($Button2, 10, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)   

            While 1
                $msg = GUIGetMsg()
                    Select
                        Case $msg = $GUI_EVENT_CLOSE or $msg = $Button2 
                            Quit()
                        Case $msg = $Button1
                    ;GUISetState(@SW_MINIMIZE)
                                                    
                    EndSelect
            WEnd
    EndFunc

Share this post


Link to post
Share on other sites

Your problem can be solved by using a protocol. When humans talk their language is their protocol. Humans must speak the same language to understand each other. The same is true for computers.

Below is a simple protocol. Items are split with a pipe character. We must learn the client and server to use this protocol.

Client:

TCPSend($socket, @ComputerName & "|" & @IPAddress1)oÝ÷ Ù'«½êÚºÚ"µÍ   ÌÍÔPÕHÔXÝ ÌÍÐÓÓPÕQÔÓÐÒÑUÉÌÍÒSVK
LLBY    ÌÍÔPÕ   ÉÝÈ  ][ÝÉ][ÝÈ[   ÌÍØQ]HHÝ[ÔÜ]
    ÌÍÔPÕ   ][Ýß  ][ÝÊB[Ê  ÌÍØQ]JB[YoÝ÷ ٩ݱêïz±!«­¢+ÙÕ¹%¹¼ ÀÌØíÍѤ)=ÁÐ ÌäíU%=¹Ù¹Ñ5½Ìäì°À¤(ÀÌØí½É´ÄôU%
ÉÑ ÅÕ½Ðí%¹½ÉµÑ¥½¸ÅÕ½Ðì°ÌÌÌ°ÄÐØ°´Ä°´Ä¤(ÀÌØí%¹ÁÕÐÄôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÀÌØíÍÑlÅt¤°ÄĤ°ÄÔÀ°ÈÀ°ÄÜÜ°Èà°ÀÌØíM}I=91d¤)U%
ÑɱMѽ¹Ð ÀÌØí%¹ÁÕÐÄ°ÄÈ°àÀÀ°À°ÅÕ½ÐíYɹÅÕ½Ðì¤)U%
ÑɱMÑIͥ饹 ÀÌØí%¹ÁÕÐÄ°ÀÌØíU%}=
-UQ

I hope this explains the idea of a protocol and gives you something simple to work with. For more information there are a ton of resources on the internet. All you have to do is grasp.

Share this post


Link to post
Share on other sites

hi manadar. sorry if i don't reply from the previous days. just got back to logon.

many thanks to you. it works like a champ now. :unsure: i am just trying to understand this "|" delimeter.

if i send three or more strings,will this "|" delimeter can split them in order? well anyway i will just try,

coz i am trying to take this string info into a listview item with their corresponding column. hope i can make it work.

thanks a lot again. :P

Share this post


Link to post
Share on other sites

hi andreik. thanks very much. yap this is what i want just like manadar replied. i just want to split the info of string into separate values. could not thought and read of this stringsplit would do the splitting.

thanks again. a way more for me to read for better understanding. :P

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  
Followers 0