anthor

Python bytes are missing after recv from UDP socket

Discussion created by anthor on Jan 10, 2013

import socket
import sys
import datetime
import os

try:
    username = "root"
    password = "Apacheah64"
    db_name = "DB_GPS"
    table_name = "Tbl_GPS"
    host = ""
    port = 6903
    buf = 4096

except IndexError:

    sys.exit(1)

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((host, port))

while 1:
    data = s.recv(buf)
    if not data:
        print("Client has exited!")
        break
    else:
        print("\nReceived message '", data,"'")

# Close socket
s.close()


the bytes i m received should be 43 bytes, but what i received from client is

Received message ' b'\x0f\x00\x00\x00NR09G05164\x00' ' ? only 15 bytes. why?

Below is Original Bytes 43 bytes

00 00 00 01 00 06 ec 44 76 a6 21 c2 00 00 08 00 45 00
00 2b 08 43 00 00 34 11 81 2b cb 52 50 db 67 0d 7a 19 24 2d
1a f7 00 17 83 26 0f 00 00 00 4e 52 30 39 47 30 35 31 36 34
00

Outcomes