Python Forum
Sending Hex Code to Machine from Laptop using TCP/IP Protocal
Thread Rating:
  • 3 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending Hex Code to Machine from Laptop using TCP/IP Protocal
#1
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()
Reply
#2
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
Reply
#3
Also, port 800 is the official 'mdbs-daemon' port, so unless that is what you are trying to communicate with, pick the appropriate port.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to summarize an article that is stored in a word document on your laptop? Mikedicenso87 2 662 Oct-06-2023, 12:07 PM
Last Post: Mikedicenso87
  sending byte in code? korenron 2 1,126 Oct-30-2022, 01:14 PM
Last Post: korenron
  I can`t find an IDE functioning in my laptop All_ex_Under 5 2,979 Aug-17-2020, 05:44 AM
Last Post: All_ex_Under
  Help For Slot Machine Code Rayaan 1 2,708 Mar-30-2020, 05:01 AM
Last Post: SheeppOSU
  run into issues while configuring visual-studio code on a win 7 machine. apollo 3 3,681 Sep-12-2019, 12:25 AM
Last Post: snippsat
  How to detect wireless modem connected serially to my laptop in python barry76 3 3,556 Jan-08-2019, 06:18 AM
Last Post: Gribouillis
  Using a Windows 7 Laptop MatthewWhebell 1 2,540 Jun-14-2018, 10:18 AM
Last Post: buran
  import keyboard module doesn't get found - working on laptop but no on raspberry pi.. HANSJORG2 1 8,167 Mar-16-2018, 02:48 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020