I'm attempting to receive data over a socket connection from a python script. I seem to be failing in how to receive this data.
Code:
intreadETH(intsock, char **msg)
{
printf("Read\n");
int n;
*msg = (char *) malloc(sizeof(char) * 256);
bzero(*msg, 256);
n = read(sock, *msg, 255);
return n;
}
Its a simple read function.
I've successfully passed a message from the host computer(python) to the server(C) with a simple message. My python code is just for testing right now.
Code:
import socket import time HOST = '192.168.99.149'
#The server's hostname or IP address
PORT = 8080
#The port used by the server
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
time.sleep(2)
s.sendall(b 'Hello, world\r')
s.detach()
s.cloe()
This works, the server receives the full message "Hello, world" with no issues. I can then send the message as many times as I want with no issues.

Now if I change the python script to look like this.
Code:
import socketimport time HOST = '192.168.99.149'
#The server's hostname or IP address
PORT = 8080
#The port used by the server
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
time.sleep(2)
packet = bytearray()
packet.append(0xBF)
packet.append(0xAB)
packet.append(0xCD)
packet.append(0xEF)
packet.append(0x0D)
bytePacket = bytes(packet)
s.sendall(bytePacket)
time.sleep(2)
s.detach()
s.close()
Both the original script and this updated script is sending messages of type bytes with a return carriage. So they look, and think, they are identical on the python side. However, I feel like on the server(C) side, they are different.
when I send the message I get this as my return

I've attempted to make changes to the print statement, but I get warnings if I change the print statement to %d, %x, or %c. Thinking the formatter just needed to be changed.
Does anyone have any insight as to what I'm missing.