I\'m a beginning C++ programmer / network admin, but I figure I can learn how to do this if someone points me in the right direction. Most of the tutorials are demonstrated
Start by reading Beej's guide on socket programming . It will bring you up to speed on how to start writing network code. After that you should be able to pick up more and more information from reading the man pages.
Most of it will consist of reading the documentation for your favourite library, and a basic understanding of man pages.
A good place to start would be to use Asio which is a great cross-platform (incl Linux) library for network communication.
You do this the exact same way you would in regular C, there is no C++ specific way to do this in the standard library.
The tutorial I used for learning this was http://beej.us/guide/bgnet/. It was the best tutorial I found after looking around, it gave clear examples and good explanations of all functions it describes.
easy:
#include <sys/socket.h>
#include <sys/types.h>
int socket(int protocolFamily, int Type, int Protocol)
// returns a socket descriptor
int bind(int socketDescriptor, struct sockaddr* localAddress, unsigned int addressLength)
// returns 0
...etc.
it's all in sys/socket.h
Poster, please clarify your question.
Almost all responses seem to think you're asking for a sockets tutorial; I read your question to mean you need to create a raw socket capable of sending arbitrary IP packets. As I said in my previous answer, some OSes restrict the use of raw sockets.
http://linux.die.net/man/7/raw "Only processes with an effective user ID of 0 or the CAP_NET_RAW capability are allowed to open raw sockets."
There are tons of references on this (of course, Stevens' book comes to mind), but I found the Beej guide to be incredibly useful for getting started. It's meaty enough that you can understand what's really happening, but it's simple enough that it doesn't take you several days to write a 'hello world' udp client/server.