Jump to content

Packet sender


Recommended Posts

Well i want to send packets to client, not server. I have searched forums and all i find is server packet sender

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

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

Example()

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 = "62.50.35.181"
    Local $nPORT = 30001

   ; Start The TCP Services
   ;==============================================
    TCPStartup()

   ; 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.
    Else
       ;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
        WEnd
    EndIf
EndFunc  ;==>Example

Can someone make it to send packets to client?

Link to comment
Share on other sites

You can't send packets to cliente if the client doesn't do the connection first.

Then the client connect to server, the serve can use the same tcp socket to send packet to client.

A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza รจ il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center]
Link to comment
Share on other sites

A client cannot connect to a client. If you wanna know how to relay stuff though a server look at the post above me

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

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...