theres something called the TCP/IP Stack.
Physical - Cable
Data link - Link layer
Network - MAC address (Hub/Switch)
Transport - Routing [IP Layer]
Session - Connection between hosts [TCP/UDP]
Presentation - HTTP protocols etc
Application - Applications that use the data
You dont need to think about the preentation layer so much if you are
writing socket programs.
But if you note the layers, there are protocols that follow this. This
stack is what everyone has to use if they want to use UDP/TCP/IP.
If the C program is using TCP you will need to use java.net.Socket.
You will have to get a protocol definition from whoever wrote the
program to find out how it works. Alternativly you can reverse engineer
the program and write you own protocol description.