Jump to content

tcp getting info from server


Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...