Network packets- >how to grab packets that are getting send by server?

basically, i want to grab network packet on server side and saved the data as a binary data in text/Database .
so I am looking for the place/function which is actually responsible to send the packets from server side and client side ?

i belief somewhere there is function like this:

sendPacket(packetData,DestinationAddress) ;

is there anything like that?