Python Forum
Sending Hex Code to Machine from Laptop using TCP/IP Protocal - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Sending Hex Code to Machine from Laptop using TCP/IP Protocal (/thread-3242.html)



Sending Hex Code to Machine from Laptop using TCP/IP Protocal - Brian_Cheong - May-08-2017

Hi all, I am a newbie in Python Programming, I am trying to send this hex code " ABBA05B80000AF11"
to reset the Machine through Tcp/ IP Protocol

Do anyone know what I have did wrong , as i was unable to " reset" the machine after i send the Hex Code ,below is my code.
Please Refer.

import socket
import sys
import struct
import time
import binascii


host = '192.168.1.40'
port = 800

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)


inputHex = binascii.unhexlify("ABBA05B80000AF11")


try:
    #remote_ip = socket.gethostbyname(host)
    s.connect((host, port))

except socket.gaierror:
    print('Hostname could not be resolved Exiting')
    sys.exit()


print('Socket connected to ' + host + ' on ip ')

try:
    while True:
        s.send(inputHex)
    print('Message sent Successfully')
    time.sleep(1)
    print('sending')

except socket.error:
    print('send fail')
    sys.exit()



RE: Sending Hex Code to Machine from Laptop using TCP/IP Protocal - Joseph_f2 - May-12-2017

Ideally, we need to know what the server-side code is like. Are you using a preexisting application which is closed source or have you made the application running on the server itself using Python? If, instead, the machine has some preexisting service installed, refer to the manual for it. Moreover, check your firewall and router settings.

Try using port scanners, such as nmap to check if the port is listening. Plus, things like VLANs and network isolation tend to interfere a lot with simple TCP/IP communication. Once you know the port is indeed open and your hex code is correct, try sending the data and printing out a dump on the server-side. If you cannot due to the software been closed-source, use WireShark.

I also see your Stack Overflow question and the comments are fairly helpful. However, any clarification you can add would be helpful.

All the best,

Joseph


RE: Sending Hex Code to Machine from Laptop using TCP/IP Protocal - sparkz_alot - May-12-2017

Also, port 800 is the official 'mdbs-daemon' port, so unless that is what you are trying to communicate with, pick the appropriate port.