Jump to content
Sign in to follow this  

I need some help with getting started TCP Send

Recommended Posts


I want make tcp send script that sends packet but when i tried example from help file i got error: TCPConnect failed with WSA error:10061.Can some one say me whats wrong here.

I want make script that sends packet to given IP.Is it possible to send binary packet?How i send 3c 28 00 00 00 ff ff ff ff to given IP and given port.

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

;CLIENT! Start Me after starting the SERVER!!!!!!!!!!!!!!!


Func Example()
    ; Set Some reusable info
    Local $ConnectedSocket, $szData
    ; Set $szIPADDRESS to wherever the SERVER is. We will change a PC name into an IP Address
;   Local $szServerPC = @ComputerName
;   Local $szIPADDRESS = TCPNameToIP($szServerPC)
    Local $szIPADDRESS = @IPAddress1
    Local $nPORT = 33891

    ; Start The TCP Services

    ; Initialize a variable to represent a connection
    $ConnectedSocket = -1

    ;Attempt to connect to SERVER at its IP and PORT 33891
    $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT)

    ; If there is an error... show it
    If @error Then
        MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error)
        ; If there is no error loop an inputbox for data
        ;   to send to the SERVER.
        ;Loop forever asking for data to send to the SERVER
        While 1
            ; InputBox for data to transmit
            $szData = InputBox("Data for Server", @LF & @LF & "Enter data to transmit to the SERVER:")

            ; If they cancel the InputBox or leave it blank we exit our forever loop
            If @error Or $szData = "" Then ExitLoop

            ; We should have data in $szData... lets attempt to send it through our connected socket.
            TCPSend($ConnectedSocket, $szData)

            ; If the send failed with @error then the socket has disconnected
            If @error Then ExitLoop

Share this post

Link to post
Share on other sites

Well there needs to be another program to receive the data... it is failing because you don't have any other programs "listening" for connections then "accepting" the connection.

Look at the TCPListen function


Share this post

Link to post
Share on other sites

tnx for fast reply.

ok i try to do some work my own now

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