C code for creating and sending a package

I would like to learn about the built-in library functions in C in order to create a complete package (along with the frame) and send it over the network ... Can anyone download the C code that does these things ... :)

+6
c network-programming packets
source share
1 answer

Here is a very simple code example for two programs that talk on a UDP socket: one list of codes creates and sends a packet, and the other receives it.

http://www.abc.se/~m6695/udp.html

Note that these network functions are not part of the C language itself, which does not support network support, but they are standard (POSIX, I think) and are available in similar forms for most modern C implementations.

Please note that with standard functions you specify only the packet payload, address, port and some flags, you cannot control the exact contents of the Ethernet frame, IP headers, etc. that are created for you by the operating system. If you need this level of control over a low-level package, I believe that you can use libpcap / winpcap for this purpose, or some operating systems may have raw sockets that allow you to do this.

+1
source share

All Articles