What i know is that applications create "socket"(visualized concept for high level programmers),the socket will address the ip addresses and send to internet and forward the feedback data.What i wonder is do applications send tcp packets directly to hardware interface or through another program like firewall?And how exactly the applications send to what program in some operating system like windows or linux?
Applications don't deal with TCP packets at all. The operating system presents an interface somewhat similar to the file system and the application just writes data to that interface. The OS deals with organizing that data into packets and sending it across the network. Likewise, received data is handled by giving the application an interface that's similar to reading from a file.
Any local firewalling is done by either an operating system module or a privileged application. In the case of connection filtering, that will check that requested connections are to allowed hosts and ports; in the case of packet filtering, the firewall will inspect the actual data flowing through the connection before it's handed to the application.
Firewalling may also be done by a gateway router. In this case, the standard IP routing system will automatically send all packets via the firewall, which will do its thing before sending them out to the internet.