Communicate through a server

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Communicate through a server

Post by Kwai chang caine »

Hello at all :D

I search a very simple way (like usually :mrgreen:) for master communicate with another slave pc, accross my serveur 1&1

In fact, using the style of method of TEAMVIEWER
Like that, no need to manage the firewall and the box ports of slave
Exe master and Exe Slave in port 80, it's open bar :lol:

So actually, with my very little knowledge of HTTP and already thanks to master INFRATEC 8) i can send commands to my server, writing a txt file on it in php with the command inside, and read with the esclave the command to execute.
But the question, in the bidet that serves as my brain :oops: it's perhaps a memory way is possible in the JS/PHP server for not need to writing each order in file, for after immediately delete it :oops:

If you know one simple method :wink:

Have a good day
ImageThe happiness is a road...
Not a destination
User avatar
mk-soft
Always Here
Always Here
Posts: 5400
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Communicate through a server

Post by mk-soft »

The first would be to immediately block port 80 again. This port is often attacked.

Furthermore you don't have to use HTTP and PHP to exchange data. HTTP also only uses TCP/IP, so you can create your own protocol and write it with PB via server-client solution. It is best to use a port that is not already defined with standards: Port 6000-7000. you can forward this port in your router to your server program.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
infratec
Always Here
Always Here
Posts: 6873
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Communicate through a server

Post by infratec »

Don't use a real webserver :mrgreen:
Write something with PB instead.

In general: normally all outgoing traffic and the answers are allowed, only incoming traffic is limited to the needed server ports.

The trick of TeamViewer and others is ...
let the user connect to something, so that the firewall/router of the user knows
that he has to allow the answers to port xyz of the customer.
Something tells the other station the open port and address for the answers.
So the other station can send data to the user directly via this address and port.

I hope this was 'understandable'.

So yoe need 'something' which is reachable from both and tell the address an port to the others.
Then they can contact each other directly via this data.
Last edited by infratec on Mon Oct 05, 2020 8:01 pm, edited 1 time in total.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Communicate through a server

Post by Kwai chang caine »

Hello MkSoft :D

First thanks for your quick answer 8)

You surely forget you speak to the worst programmer of the WEST :mrgreen:
your own protocol and write it
Only in my dreams :oops: :lol:
It is best to use a port that is not already defined with standards: Port 6000-7000
Justely, software like the simple VNC SC (Simple clic) use this style of port and each time it's really difficult for me to configure on a WLAN network :oops:
This is why i say to me, using PB master with HTTPRequest for put command on my server 1&1 and PB slave with HTTPRequestMemory for take the master command and execute it.
I have try that and nothing is locked :shock: because it's exactely what Firefox do all the day when i go to a site :wink:
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Communicate through a server

Post by Kwai chang caine »

I hope this was 'understandable'.
Image

Not for little KCC :oops: :oops:
ImageThe happiness is a road...
Not a destination
infratec
Always Here
Always Here
Posts: 6873
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Communicate through a server

Post by infratec »

Wow, you got entrance to Area 51 :!:
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Communicate through a server

Post by Kwai chang caine »

Wow, you got entrance to Area 51
:lol: :lol:

No it's just my head when i crying :lol: :lol:
ImageThe happiness is a road...
Not a destination
infratec
Always Here
Always Here
Posts: 6873
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Communicate through a server

Post by infratec »

Something:

Code: Select all

EnableExplicit

Structure ClientStructure
  IP.i
  Port.i
EndStructure


Define.i Server, Client, Len, Pos
Define Buffer$, Session$
Define *Buffer

NewMap ClientMap.ClientStructure()

InitNetwork()

Server = CreateNetworkServer(#PB_Any, 80)
Debug Server
If Server
 
  *Buffer = AllocateMemory(1024)
  If *Buffer
   
    Repeat
     
      Select NetworkServerEvent()
        Case #PB_NetworkEvent_Data
          Debug "NetworkEvent_Data"
          Client = EventClient()
          Len = ReceiveNetworkData(Client, *Buffer, MemorySize(*Buffer))
          If Len
            Buffer$ = PeekS(*Buffer,Len, #PB_UTF8|#PB_ByteLength)
            Pos = FindString(Buffer$, "Session:")
            If Pos
              Session$ = Mid(Buffer$, Pos + 8)
              Debug "Session:" + Session$
              If FindMapElement(ClientMap(), Session$)
                Debug "Found"
                ;If ClientMap()\IP <> GetClientIP(Client) And ClientMap()\Port <> GetClientPort(Client)
                If ClientMap()\Port <> GetClientPort(Client)
                  SendNetworkString(Client, "Connect:" + IPString(ClientMap()\IP) + ":" + Str(ClientMap()\Port))
                  DeleteMapElement(ClientMap())
                Else
                  SendNetworkString(Client, "Wait")
                EndIf
              Else
                Debug "New"
                If AddMapElement(ClientMap(), Session$)
                  ClientMap()\IP = GetClientIP(Client)
                  ClientMap()\Port = GetClientPort(Client)
                  SendNetworkString(Client, "Create:" + IPString(ClientMap()\IP) + ":" + Str(ClientMap()\Port))
                EndIf
              EndIf
            EndIf
          EndIf
         
        Case #PB_NetworkEvent_None
          Delay(10)
      EndSelect
     
    ForEver
   
    FreeMemory(*Buffer)
  EndIf
 
EndIf
Client:

Code: Select all

EnableExplicit


Define.i Con, Len, Server
Define Buffer$
Define *Buffer

InitNetwork()

Con = OpenNetworkConnection("localhost", 80)
Debug Con
If Con
  SendNetworkString(Con, "Session:1234")
  
  *Buffer = AllocateMemory(1024)
  If *Buffer
    
    Repeat
      Select NetworkClientEvent(Con)
        Case #PB_NetworkEvent_Data
          Len = ReceiveNetworkData(Con, *Buffer, MemorySize(*Buffer))
          If Len
            Buffer$ = PeekS(*Buffer, Len, #PB_UTF8|#PB_ByteLength)
            Debug Buffer$
            If Left(Buffer$, 7) = "Create:"
              Debug StringField(Buffer$, 3, ":")
              
              CloseNetworkConnection(Con)
              
              Server = CreateNetworkServer(#PB_Any, Val(StringField(Buffer$, 3, ":")))
              Debug "Server:" + Str(Server)
              If Server
                Repeat
                  Select NetworkServerEvent()
                    Case #PB_NetworkEvent_Data
                      Len = ReceiveNetworkData(EventClient(), *Buffer, MemorySize(*Buffer))
                      If Len
                        Debug PeekS(*Buffer, Len, #PB_UTF8|#PB_ByteLength)
                      EndIf
                    Case #PB_NetworkEvent_None
                      Delay(10)
                  EndSelect
                ForEver
              EndIf
            EndIf
          EndIf
          
        Case #PB_NetworkEvent_None
          Delay(10)
      EndSelect
    ForEver
    
    FreeMemory(*Buffer)
  EndIf
  
EndIf
Connector:

Code: Select all

EnableExplicit


Define.i Con, Len
Define Buffer$
Define *Buffer

InitNetwork()

Con = OpenNetworkConnection("localhost", 80)
Debug Con
If Con
  SendNetworkString(Con, "Session:1234")
 
  *Buffer = AllocateMemory(1024)
  If *Buffer
   
    Repeat
      Select NetworkClientEvent(Con)
        Case #PB_NetworkEvent_Data
          Len = ReceiveNetworkData(Con, *Buffer, MemorySize(*Buffer))
          If Len
            Buffer$ = PeekS(*Buffer, Len, #PB_UTF8|#PB_ByteLength)
            If Buffer$ <> "Wait"
              Debug Buffer$
              If Left(Buffer$, 8) = "Connect:"
                Debug StringField(Buffer$, 2, ":") + " " + StringField(Buffer$, 3, ":")
                CloseNetworkConnection(Con)
                Con = OpenNetworkConnection(StringField(Buffer$, 2, ":"), Val(StringField(Buffer$, 3, ":")))
                Debug Con
                If Con
                  Debug "Send Hello"
                  SendNetworkString(Con, "Hello")
                  Delay(1000)
                EndIf
              EndIf
            EndIf
          EndIf
         
        Case #PB_NetworkEvent_None
          Delay(10)
      EndSelect
    ForEver
   
    FreeMemory(*Buffer)
  EndIf
 
EndIf
Start them in this order.

I will have a look tomorrow when I run it on 3 different PCs.
Last edited by infratec on Tue Oct 06, 2020 7:26 am, edited 1 time in total.
infratec
Always Here
Always Here
Posts: 6873
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Communicate through a server

Post by infratec »

Corrected the stuff above.

Works now on one local PC.
I have to check it on different networks. (change the addresses!)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Communicate through a server

Post by Kwai chang caine »

One thousand of thanks MASTER :shock:
That works here 8)

But if the slave are not on local, That works also good ?
Furthermore the firewall ask to confirm, and it's a difficulty when the user of the slave machine is my old stepmother or my brother, who just know to push on on/off button :|

I search to do something like TEAMVIEWER, but in very very more simple, not security, not password
In the first time not RDP, just send command line like "create/delete folder/File", run exe, open HTML page, etc ...
After perhaps send screenshots, move mouse, enumerate folderfiles, etc ...

It's for help quickly several persons of my familly, in one clic, without have all this complex procedure to connect, etc ....
Because Teamviewer annoy me with all this update, the soft is more and more difficult to install, imposible for my familly, and i'm at the other side of the network, and i can't help them, because she not know how download new version and install it
I'm forcing to wait one or several months for install the new versions, adjust parameter on his local machine :evil:

I want create a personal tools very dangerous for the security, but often, i just need to do something during 15 mn and when my familly his in front of his machine for watch and help me by phone to do what he want :wink:
It's the reason why, i have this idea to send orders by my 1&1 server, like this, nothing to accept in the slave machine, just run the exe and wait little KCC send command

Image

And save the very "pleasant and sweet" stepmother who hate the informatic :oops: and to see his "smile" :lol:
ImageThe happiness is a road...
Not a destination
normeus
Enthusiast
Enthusiast
Posts: 415
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: Communicate through a server

Post by normeus »

KCC,

It sounds like what you have going is working for you.
To delete a file in PHP look at the PHP unlink() instruction:
https://www.php.net/manual/en/function.unlink.php

I use VNC, which is free; to communicate with my local computers. You might want to try it.
(I've heard people using it as Teamviewer with a 2nd program managing the portforwarding being sent to a server on the web)

Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: Communicate through a server

Post by Olli »

KCC wrote:No it's just my head when i crying
Mytho !

It is the son of your neighbour, when he came searching the candies for Halloween, the last year. You joked again, giving him any keys of keyboard in a bag...
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Communicate through a server

Post by Kwai chang caine »

@NORMEUS

Thanks for your help 8)
Yes i have found for delete file in PHP :wink:

In fact, i search to not write a file, like this file is immediately deleted, i say to me it's perhaps faster to keep in memory the master order and send it to the slave
But i have not find how to do that (Passing a variable between two PHP cession, put in a variable and share it in PHP, etc ...)

My idea it's very simple and always working, because it's just request like the navigator do all the time
Like this, no password, no identification, no firewal locking or asking, no install, no port adjusting (all in 80) just run master and slave exe :idea: :D

Method of death so simple it is : :mrgreen:

1/ Master send "CreateTxt KccFile.txt" to my 1&1 serveur by a http request
2/ My server writing a PHP txt file "Command.txt" with master order inside
3/ The esclave always ask to 1&1 server if he have a "command.txt" file
4/ As soon my 1&1 serveur have a "command.txt" file, the slave read and execute it :D
5/ The slave return to 1&1 server the answer (File created or not)
6/ The 1&1 create a text file "Answer.txt" with answer of slave inside
7/ The master read the "Answer.txt" and know if the file "KccFile.txt" is good created on the slave machine

And the miracle appears before the KCC dumbfounded eyes

Image

The " KccFile.txt" file is creating on the slave, without panel ok, locking, etc ... :evil: it's magic :shock: :D

Easier you die :lol:
But i search, a way for do exactely that without create file on server, all in memory of server and 2 machines :oops:

After with this method you can all do on the other machine, all what PB can do on a local machine, then nearly ALL
Even send screenshot, enumerate folders files, etc .... and even create in master a explorerlist and reproduce the desktop with many works

Sure it's not also faster and nice than TeamViewer or VNC, but i use also me too this two softs, and i'm tired to always need to update teamviewer, enter complex password, or modify my router for port 5800/5900 sometime firewall lock and i don't know why great mother is always alone :twisted:

In fact, just a simple tool, for always sure to can take control on the other machine, because each time, i spend more time to connect to the slave, than help it (And again, when it's works) and i want to throw the pc down

Image
Normeus wrote:I use VNC, which is free; to communicate with my local computers. You might want to try it.
I know there are a method for use VNC without modify port on box, all in 80, but i have try and never success to access to the slave on the WLAN
In local mode, all works, but when it's for great mother .....

Image

It's another history and she feels a little lonely in the depths of her countryside with this big calculator :cry:

@OLLI
:lol: :wink:
ImageThe happiness is a road...
Not a destination
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Communicate through a server

Post by Marc56us »

Kwai chang caine wrote:Justely, software like the simple VNC SC (Simple clic) use this style of port and each time it's really difficult for me to configure on a WLAN network :oops:
<off topic, but hope this help>
If you always troubleshoot your users from the same place, use PCHelpWare (V1, not V2). It is the successor of SimpleClick.
If you have a fixed IP address you have only one address translation to do on your box. Otherwise use a dynamic dns.
You can also use the repeater.
Notes: the explanations found on the net to generate the EXE are all more unreadable one than the other, but after a lot of tests it works very well.
When I have time, I will try to make a help page on my site for this system because it took me two days to get it working. But it's works now.
</off>
:wink:
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Communicate through a server

Post by Kwai chang caine »

My dear Marc, you are always an angle for me 8)

I continue to programming my "cowpatware" :mrgreen:
Even a children of ten years old can do better, but i'm enough proud of the result :shock: 8)
In fact it's really simple to fully remote another machine through all the security, Firewall and other..., just by use create/delete file by PHP or FTP on server

Normally with my soft, just run one exe on each machine and master can do on the slave all what PB can do, so nearly ALL 8) The total control what :D my dream
No password, encryption, security, the highway of insecurity, exactely what all good programmer never create :mrgreen:
But this time...i'm really sure to never is locked by a firewall or security :twisted: for help great mother 8)

Sure....have RDP module is the real dream for adding to my soft, because it's more in command line "like the real ones on TV" :mrgreen:
But for the moment ...all do by command lines is already good
ImageThe happiness is a road...
Not a destination
Post Reply