Networking and Network Programming 2 TCP/IP phần 9

Đọc dữ liệu đã được nhận được ổ cắm. / / / / Chức năng này có một con trỏ đến một số nguyên sẽ được lấp đầy với chiều dài của các dữ liệu đọc / /. / / / / Con trỏ đến dữ liệu được trả về trên thành công. Các ứng dụng / / sử dụng đối tượng này phải miễn phí này con trỏ. NULL được trả về về thất bại. | Part IV Programming with the WinSock Class Library Listing . continued void CMainView OnInitialUpdate get pointer to list box used for status messages CListBox plb CListBox GetDlgItem IDC_LIST_STATUS initialize the WinSock object m_pWinSock new CWinSock if m_pWinSock- Startup CWINSOCK_NOERROR plb- InsertString 0 WinSock initialized else plb- InsertString 0 WinSock initialization failed delete m_pWinSock m_pWinSock NULL return initialize the stream socket object m_pStreamSrv new CStreamSocket this WM_USER_STREAMSRV if m_pStreamSrv- CreateSocket 2000 CWINSOCK_NOERROr plb- InsertString 0 Stream server created port 2000 else plb- InsertString 0 Stream server creation failed delete m_pStreamSrv m_pStreamSrv NULL BEGIN_MESSAGE_MAP CMainView CFormView AFX_MSG_MAp CMainView ON_MeSSAGE WM_uSeR_STREAmSrv OnStreamSrv ON_MESSAGe wM_USER_STREAM OnStream AFX_MsG_MAP END_MESSAGE_MAP CMainView message handlers CMainView OnStreamSrv Receives messages from the stream server object. LONG CMainView OnStreamSrv WPARAM wParam LPARAM lParam get pointer to list box used for status messages CListBox plb CListBox GetDlgItem IDC_LIST_STATUS switch wParam Chapter 14 Sample Applications case CWINSOCK_READY_TO_ACCEPT_CONNECTION make sure the server is not already servicing a client if m_pStream NULL plb- InsertString 0 Already servicing a client break accept the client connection int nStatus m_pStream new CStreamSocket this WM_USER_STREAM nStatus m_pStreamSrv- Accept m_pStream if nStatus CWINSOCK_NOErRoR delete m_pStream m_pStream NULL plb- InsertString 0 Error accepting client connection break else plb- InsertString 0 Accepted client connection break default break return 0L CMainView OnStream Receives messages from the connected stream object. LONG CMainView OnStream WPARAM wParam LPARAM lParam LPVOID pDataWritten pointer to data that is completely written LPVOID pDataRead pointer to data just read int nLen length char pszMessage 1000 informational message SOCKADDR_IN sin Internet address

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.