Jump to content
Sign in to follow this  
testingtest

tcp getting info from server

Recommended Posts

testingtest

hello i need some help please

i want to get info from the server for example the computer name and then send the computer name over to the client

i know i would have to use TCPRecv and and TCPSend but how do i tell it what info i want from the socket

i bet it's not even hard to do but for me to have to think of the process is hurting my head i tell it what socket i am connected to and tell it how much data i want send and recv but no option to pick the data you want back

Share this post


Link to post
Share on other sites
Nahuel

You want something like this?

Server:

;Server Script. RUN FIRST
TCPStartUp()
$MainSocket = TCPListen(TCPNameToIP(@computername), 65432,  100 )
If $MainSocket = -1 Then Exit
While 1
    $ConnectedSocket = TCPAccept( $MainSocket)
    If $ConnectedSocket >= 0 Then
        msgbox(0,"","connected",1)
        ExitLoop
    EndIf
Wend
While 1
    $Message=TCPRecv($ConnectedSocket,2048)
    Sleep(25)
    If $Message<>"" Then
        Switch $Message
            Case "IPAddress"
                $Info=@IPAddress1
            Case "ComputerName"
                $Info=@ComputerName
            Case "UserName"
                $Info=@UserName
            Case "LogonDomain"
                $Info=@LogonDomain              
            Case Else
                $Info="Unknown command"
        EndSwitch
        TCPSend($ConnectedSocket,$Info)
    EndIf
WEnd

Run the server at the remote computer, then run the client at yours. Enter the info you want to get from the server (IPAddress,ComputerName,UserName,etc...)

Should work.

Share this post


Link to post
Share on other sites
testingtest

Thanks just what I wanted your my hero <_<

Edited by testingtest

Share this post


Link to post
Share on other sites
jokke

you sure you have port 65432 open?

Edit: and forwarded to your server computer. (inncase you are running this script over internet)

Edited by jokke

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites
magician13134

Sorry, I deleted it because I got it working with IP 192.168.0.11... but now I'm trying it with a friend, and I can't get it working again. How do I know if the port is open? And do the computers need to be on the same network? Or could I be running this script with someone halfway across the globe?

Edited by magician13134

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.