Tham khảo tài liệu 'web client programming with perl-chapter 4: the socket library- p1', công nghệ thông tin, quản trị web phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 4 The Socket Library- P1 The socket library is a low-level programmer s interface that allows clients to set up a TCP IP connection and communicate directly to servers. Servers use sockets to listen for incoming connections and clients use sockets to initiate transactions on the port that the server is listening on. Do you really need to know about sockets Possibly not. In Chapter 5 The LWP Library we cover LWP a library that includes a simple framework for connecting to and communicating over the Web making knowledge of the underlying network communication superfluous. If you plan to use LWP you can probably skip this chapter for now and maybe forever . Compared to using something like LWP working with sockets is a tedious undertaking. While it gives you the power to say whatever you want through your network connection you need to be really careful about what you say if it s not fully compliant with the HTTP specs the web server won t understand you Perhaps your web client works with one web server but not another. Or maybe your web client works most of the time but not in special cases. Writing a fully compliant application could become a real headache. A programmer s library like LWP will figure out which headers to use the parameters with each header and special cases like dealing with HTTP version differences and URL redirections. With the socket library you do all of this on your own. To some degree writing a raw client with the socket library is like reinventing the wheel. However some people may be forced to use sockets because LWP is unavailable or because they just prefer to do things by hand the way some people prefer to make spaghetti sauce from scratch . This chapter covers the socket calls that you can use to establish HTTP connections independently of LWP. At the end of the chapter are some extended examples using sockets that you can model your own programs on. A Typical Conversation over Sockets The basic idea behind sockets as with all .