You don't need to worry about all that... (especially packets and how they really work).
All modern operating systems and programming languages (and libraries) allow access on a higher level, actual access to packets is rarely needed (except for sniffing, intrusion detection, ...etc.);
If you want to create a client and a server I recommend using
Net::EasyTCP as another poster said.
See
my post about making any script that uses stadard input and standard output to
Servers using
xinetd in
this thread.