I need to calculate the packet size of a tcp/ip packet and send this size as the first int to the server.
You can't. You can only calculate the size of your data. The packet size will vary as you packet traverses the Internet.What do you need it for?