Python bytes are missing after recv from UDP socket

1075
0
01-10-2013 09:02 PM
hellohello
New Contributor

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
Tags (2)
0 Kudos
0 Replies