PHP Game Programming 2004 phần 7

GD cung cấp cho bạn với một chức năng được gọi là ImageArc () để tạo ra, tốt, vòng cung. Điều này không bao giờ nên xảy ra, để cảnh báo các lập trình viên / / (họ có thể quên require_once lệnh) echo "COMMAND UNKNOWN "; / / xuất cảnh khó khăn, vì không có gì khác chúng ta thực sự có thể làm xuất cảnh | This page intentionally left blank CHARTER 10 PHP AND Sockets Socket Basics Creating a Server Creating a Client In this chapter you will explore the fascinating and sometimes confusing world of sockets. Sockets must be one of the most underused components in PHP. Today you ll take a look at how to create a server to which a client can connect how to connect to a server from a client using sockets and how to process information on the server and send it to the destination client. Believe it or not you have been using sockets the entire time you ve been programming in PHP. The server is the HTTP server that you connect to and the client is the Web browser you are using to connect to the server. This is a single client server relationship. Socket Basics PHP uses the Berkley sockets library to make its connections. You can think of a socket as nothing more than a data structure. You use this socket data structure to start a conversation between a client and a server. The server is always listening to open a new conversation. When a client wants to talk to the server it opens a conversation through a specific port on which the server is listening. When the server receives the client s request it completes the connection thus completing the cycle. Now the client can send information to the server and the server can send information to the client. 213 214 Chapter 10 PHP and Sockets To create a socket you will need three variables a protocol a socket type and a common protocol type. There are three protocols that you can choose from when creating a socket. Take a look at Table for the names of the protocols and a description of what each protocol does. When you create your own server you will use the AF_INET protocol. There are five socket types to choose from in the Berkley socket library. Please refer to Table for the constant and a description of the socket type. The final element to creating a socket is to define the type of common protocol that the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.