Jump to content

Recommended Posts

Posted

Hello,

I've a simple socket script in python on a linux machine :
 

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('', 6542))
s.listen(5)
conn, addr = s.accept()
while True:
    data = conn.recv(1024)
    if not data:
        break
    print data
    conn.sendall("TEST EMISSION")
conn.close()


I would like send data with autoit... 
 

#include <MsgBoxConstants.au3>

Example()

Func Example()
    TCPStartup() ;
    OnAutoItExitRegister("OnAutoItExit")
    Local $sIPAddress = "10.40.16.212" 
    Local $iPort = 6542 
    Opt("TCPTimeout", 3000

    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    If @error Then
        Local $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Connexion impossible, code d'erreur: " & $iError)
        Return False
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Connection réussie")
    EndIf
    TCPCloseSocket($iSocket)
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() 
EndFunc  


It doesn't work. I try AUTOIT with AUTOIT it's ok. Python with python too... 
Some ideas?

Thanks in advance

Posted

Hi.. and welcome to the forums. Unfortunately, "doesn't work" isn't enough details for us to help you. Please provide a more detailed description of what is occurring. I assume that 10.40.16.212 is the IP address of the linux machine. Is it on the same subnet as your Windows machine? Any chance there's a firewall between them?

I'm not sure if it's simply a copy / paste issue, but the line containing Opt("TCPTimeout" is missing a closing parentheses. Also, here's the proper way to post code in the future.

Posted

Hello,

Sorry,
TCPConnect return the error code 10060.
The two computer aren't in the same subnet but On the same port, and between the same machine two script python work well.
For the line Opt it's a mistake in the copy paste.

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
  • Recently Browsing   0 members

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