I've searched through my code. .. as far as I can see I am only
sending 12 bytes but recv is returning 1000000 bytes. Can anyone
provide me with any insight as to why this is?
1) Show us your code. Your verbal description is way too vague to be
of any assistance in determining what went wrong.
2) recv() isn't a standard C function; you might get better help from
a forum which addresses POSIX functions (a forum dedicated to your
execution platform would probably be the best bet).
3) (OFF TOPIC) Remember that TCP is an /octet-oriented stream/
protocol; the receiver will receive all the data, octet-by-octet, in
the order you sent it, *but* there is no guarantee that the receiver
will receive that data in the same "bundles" as you sent it. You may
send 10 bundles of 12 characters each, and the receiver can
legitimately receive 5 bundles of 24 characters, or even 1 bundle of
120 characters.
4) (OFF TOPIC) Remember that UDP is an all-or-nothing, unassured
delivery packet protocol, with a maximum packet size (in TCP/IP v4) of
64Kbytes. The receiver /cannot/ receive more than 64Kb at one time
(nor can the sender /send/ more than 64Kb at a time), so if the
receiver reports more than 64Kb received, then it is likely that the
receiver has a logic error.
Find the proper forum for your problem.
Post your code (the smallest code that exhibits the aberrant
behaviour). Show your results.
Then, your audience can help you