Jump to content

TCP Examples and Scripts


themax90
 Share

Recommended Posts

  • 5 weeks later...
  • Replies 47
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 3 weeks later...

I am curious to learn how far along you are in developing an AutoIt based packet sniffer. Thank you for your hard work.

Only basic research on Etheral. Not much has been done in the line of research because AutoIt will take time to support the capability. Most likely I will end up using a winsock library and C++ for it. But because there is not avialible functionality or threading capabilities, a packet sniffer may take a while.

I will research more since someone seems interesting in the topic.

AutoIt Smith

P.S. I really miss the good old blizzhackers....

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...

Just wanted to say thanks and good work, Smith. Not that I am interested in TCP, but I think your std IO scripts you have in your fileman will be exactly what I need to make a Java/AutoIt Bridge. I have been having problems reading and writing from the stdIO, but you made it work!

Thanks a mil, you are The Dude!

Link to comment
Share on other sites

  • 2 months later...

Hi, does anybody know a simple method with which i can ckeck if a socket does no longer exist ?

My programs:[topic="40019"]Sudoku[/topic], [topic="41258"]Suitcase game & Random jokes[/topic], [topic="41641"]8 Queens[/topic], [topic="41679"]Puzzle Generator[/topic], [topic="42045"]Snake[/topic]My UDFs:[topic="41309"]Prime functions & Prime game[/topic]Other:Fake emailer
Link to comment
Share on other sites

Smith, I support your idea of this becoming a sticky because several people have trouble with TCP and others don't understand anything about it. These are excellent examples, and I've learnt alot when studying these scripts. TCP is my weakness and this is very handy for people like me.

Keep up the good work :)

Kurt

Edited by _Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 months later...

Hey, i've been working with auto-it for about a year now... and i kno this is probably a very stupid question... but how the hell do i host the server? it seems to not work when i try to run from my computer

Link to comment
Share on other sites

  • 1 month later...

Hey, i've been working with auto-it for about a year now... and i kno this is probably a very stupid question... but how the hell do i host the server? it seems to not work when i try to run from my computer

Camden, I am amazed that no-one has answered you in nearly about 6 weeks, and it was your first post as well.

Can you tell us which scripts you were trying and what the error or problem was when you tried to run them?

The question isn't at all stupid, but maybe you would have got a reply earlier if you had given more information.

Welcome to the forums, belatedly if you've been observing for a year. Don't let the absence of any response until now discourage you. Questions often go unanswered and once they are a couple of days old the thread can slip out of sight. If this happens in the future you can simply 'bump' it up to the top again by adding another post, someone is sure to help eventually.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 5 months later...
  • 1 month later...

Hi, guys! I was just trying to make a very simple script, but I am kind of new to TCP/UDP and I was wondering if I could get a little advice. You can just ignore the GUI cause I really need to connect the two PCs first :) The problem is that as soon as I start the programs on both PCs the listening port just yells it cannot connect. The IPs are there just so i don't have to type them every time I run the scripts. Please write some suggestions how to fix this :):party:.

#include <GUIconstants.au3>
opt ("TCPtimeout",15000)
Guicreate ("Chat - Server",300,300)
opt ("Guioneventmode",1)
$x=10
$y=200
Dim $ar[10000]
TCPStartup()
$ip="85.130.20.205"
$port=1337
$lp=TCPConnect($ip,$port)
$send=GUICtrlCreateInput("",10,240)
$b=GUICtrlCreateButton("Send",100,240)
GUISetOnEvent($b,"sent")
if $lp=-1 Then
    MsgBox (0,"Error","Can't connect!")
    TCPShutdown()
    exit
EndIf
GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE,"close")
dim $i=0

While 1
    $data=TCPRecv($lp,512)
    If $data <> "" Then
        if $i>1 then
        for $m=0 to $i-1 step 1
            $y=$y-20
            GUICtrlSetPos($ar[$i],$x,$y)            
        next
        endif
        $y=200
        $ar[$i]=GUICtrlCreateLabel($data,$x,$y)
        $i=$i+1
    EndIf
WEND

func close()
    TCPCloseSocket($lp)
    TCPShutdown()
    Exit
EndFunc

func sent()
    TCPSend ($lp,GUICtrlRead($send))
EndFunc

//That's the code of the connecting one

#include <GUIconstants.au3>
opt ("TCPTimeout",15000)
Guicreate ("Chat - Client",300,300)
opt ("Guioneventmode",1)
$x=10
$y=200
Dim $ar[10000]
TCPStartup()

Global $MainSocket
$send=GUICtrlCreateInput("",10,240)
$b=GUICtrlCreateButton("Send",100,240)
GUISetOnEvent($b,"sent")
Local $MaxLength = 512;
$ip="85.130.35.139"
$port=1337
GUISetOnEvent($GUI_EVENT_CLOSE,"close")
$MainSocket = TCPListen($ip, $port)
if $MainSocket=-1 then
TCPShutdown()
Exit
Endif
dim $i=0
GUISetState()

While 1
    $data=TCPRecv($MainSocket,512)
    If $data <> "" Then
        if $i>1 then
        for $m=0 to $i-1 step 1
            $y=$y-20;85.130.20.205
            GUICtrlSetPos($ar[$i],$x,$y)            
        next
        endif
        $y=200
        $ar[$i]=GUICtrlCreateLabel($data,$x,$y)
        $i=$i+1
    EndIf
    
WEND

func close()
    TCPCloseSocket($MainSocket)
    TCPShutdown()
    Exit
EndFunc


func sent()
    TCPSend ($MainSocket,GUICtrlRead($send))
EndFunc

//And that is the listening one.

Edited by mladost1
Link to comment
Share on other sites

Hi, guys! I was just trying to make a very simple script, but I am kind of new to TCP/UDP and I was wondering if I could get a little advice. You can just ignore the GUI cause I really need to connect the two PCs first :) The problem is that as soon as I start the programs on both PCs the listening port just yells it cannot connect. The IPs are there just so i don't have to type them every time I run the scripts. Please write some suggestions how to fix this :):party:.

The first thing you need to do is make the $ip address on the client and the server match. You don't want the client connecting to itself, but rather, trying to connect to the server's ip address.

Then add this code snippet from the OP's server example to your server's While loop:

If $ConnectedSocket = -1 Then
        $ConnectedSocket = TCPAccept($MainSocket)
        If $ConnectedSocket <> -1 Then
; Someone Connected
            TCPSend($ConnectedSocket, "Connected!")
        EndIf
EndIf

You'll also want to declare this outside the loop:

$ConnectedSocket = -1

Then change this line:

$data=TCPRecv($MainSocket,512) to:

$data=TCPRecv($ConnectedSocket,512)

I'm pretty sure that's all I changed and was able to get your client to connect.

You want to receive data from a client, and it's the $ConnectedSocket = TCPAccept($MainSocket) line that tells you what that client's SocketID is. Your $MainSocket is only returning the main socket identifier, surprisingly. ^_^

Let me say that I'm very new to sockets and AutoIt, but hopefully this helps you along. And anyone, please correct any mistakes I've made in this post. I won't get mad :lmao:

--Kris

Link to comment
Share on other sites

i have a problem to:

if i use TCPListen(@IPAddress1,4999) on a computer that is on a network (@IPAddress1 = 192.168.1.64) it wont connect

i even tryed TCPListen(_GetIP(),4999) with diffrent ports and it stil wont connect

do you have any ideea how to maked work???

Link to comment
Share on other sites

  • 2 weeks later...
  • 8 months later...

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