MỘT SỐ KHÁI NIỆM CƠ BẢN VỀ WINSOCK
Số trang: 7
Loại file: doc
Dung lượng: 65.50 KB
Lượt xem: 15
Lượt tải: 0
Xem trước 0 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
WinSock API (Windows Sockets Application Programming Interface) là thư viện các hàm giaodiện lập trình mạng cho Microsoft Windows. WinSock tương thích với họ nghi thức mạngTCP/IP.
Nội dung trích xuất từ tài liệu:
MỘT SỐ KHÁI NIỆM CƠ BẢN VỀ WINSOCKMỘ Ố TSKHÁINI ƠẢ ề ỆMC B Nv winsock :WinSock :WinSock API (Windows Sockets Application Programming Interface) là thư viện các hàm giaodiện lập trình mạng cho Microsoft Windows. WinSock tương thích với họ nghi thức mạngTCP/IP.Socket :Socket là đầu (endpoint) trao đổi dữ liệu giữa các quá trình, qua đó các ứng dụng WinSock gởi /nhận dữ liệu qua mạng.Hai loại Socket :Stream Socket :Dựa trên nghi thức TCP ( Tranmission Control Protocol ), việc truyền dữ liệu chỉ thực hiện giữahai quá trình đã thiết lập kết nối. Dữ liệu được truyền tin cậy, đúng trình tự và không lập lại.Dữ liệu được truyền như dòng liên tục các byte không phân biệt ranh giới các recordDatagram Socket :Dựa trên nghi thức UDP ( User Datagram Protocol ), việc truyền dữ liệu không yêu cầu có sựthiết lập kết nối giữa hai quá trình. Dữ liệu truyền không tin cậy, có thể không đúng trình tự hoặclập lại.Dữ liệu được truyền như dòng các record.Port :Port xác định duy nhất một quá trình trên một máy trong mạng.Một TCP/IP Socket gồm một địa chỉ IP kết hợp với một port ? xác định duy nhất một quá trìnhtrên mạng.Một số port dành riêng :UDP Ports :0 Reversed7 Echo37 Time42 Name Server53 Domain Name Server69 Trivial File Transfer Program ( TFTP )514 System Log..........TCP Ports :0 Reversed1 TCP Multiplexor20 FTP_ Data Connection21 FTP_ Command Connection23 TELNET25 SMTP42 Name Server53 Domain Name Server79 Finger_ find a active user.....................Lập trình winsockCác file cần thiết :WINSOCK.DLL hay WSOCK32.DLL ( tuỳ version 16 hay 32 bit của Windows ).WINSOCK.LIB hay WSOCK32.LIB.WINSOCK.H.Giới thiệu một số hàm của WinSock:Dưới đây chỉ giới thiệu chức năng của một số hàm WinSock, không trình bày prototype của cáchàmCác hàm khởi động WinSock :Dùng để khởi đầu và kết thúc quá trình sử dụng WinSock.WSAStartup() : Khởi động WinSock.WSACleanup() : Kết htúc WinSock.WSAGetLastError() : Lấy mã sai vừa xảy ra.Các hàm Socket :Dùng để thiết lập quá trình trao đổi dữ liệu trên mạng.socket() : tạo socket truyền dữ liệu.bind() : định danh cho socket vừa tạo (gán port cho socket).listen() : lắng nghe kết nối.accept() : chấp nhận kết nối từ client.connect() : kết nối với server.send(), recv() : gởi, nhận dữ liệu với stream socket.sendto(), recvfrom() : gởi, nhận dữ liệu với datagram socket.........Các hàm khác :inet_addr() : chuyển từ địa chỉ IP dạng số thập phân có chấm sang địa chỉ internet.inet_ntoa() : ngược lại.gethostname() : cho tên máy hiện hành.gethostbyname(),WSAAsyncGetHostByName(): cho địa chỉ IP ứng với tên máy.gethostbyaddr(),WSAAsyncGetHostByAddr(): cho tên máy ứng với địa chỉ IP.........WinSock error:Lỗi khi send dataWSANOTINITIALISED A successful AfxSocketInit must occur before using this API.WSAENETDOWN The Windows Sockets implementation detected that the network subsystemfailed.WSAEACCES The requested address is a broadcast address, but the appropriate flag was notset.WSAEINPROGRESS A blocking Windows Sockets operation is in progress.WSAEFAULT The lpBuf or lpSockAddr parameters are not part of the user address space, or thelpSockAddr argument is too small (less than the size of a SOCKADDR structure).WSAENETRESET The connection must be reset because the Windows Sockets implementationdropped it.WSAENOBUFS The Windows Sockets implementation reports a buffer deadlock.WSAENOTCONN The socket is not connected (SOCK_STREAM only).WSAENOTSOCK The descriptor is not a socket.WSAEOPNOTSUPP MSG_OOB was specified, but the socket is not of type SOCK_STREAM.WSAESHUTDOWN The socket has been shut down; it is not possible to call SendTo on a socketafter ShutDown has been invoked with nHow set to 1 or 2.WSAEWOULDBLOCK The socket is marked as nonblocking and the requested operation wouldblock.WSAEMSGSIZE The socket is of type SOCK_DGRAM, and the datagram is larger than themaximum supported by the Windows Sockets implementation.WSAECONNABORTED The virtual circuit was aborted due to timeout or other failure.WSAECONNRESET The virtual circuit was reset by the remote side.WSAEADDRNOTAVAIL The specified address is not available from the local machine.WSAEAFNOSUPPORT Addresses in the specified family cannot be used with this socket.WSAEDESTADDRREQ A destination address is required.WSAENETUNREACH The network cannot be reached from this host at this time.Lỗi khi receive dataWSANOTINITIALISED A successful AfxSocketInit must occur before using this API.WSAENETDOWN The Windows Sockets implementation detected that the network subsystemfailed.WSAENOTCONN The socket is not connected.WSAEINPROGRESS A blocking Windows Sockets operation is in progress.WSAENOTSOCK The descriptor is not a socket.WSAEOPNOTSUPP M ...
Nội dung trích xuất từ tài liệu:
MỘT SỐ KHÁI NIỆM CƠ BẢN VỀ WINSOCKMỘ Ố TSKHÁINI ƠẢ ề ỆMC B Nv winsock :WinSock :WinSock API (Windows Sockets Application Programming Interface) là thư viện các hàm giaodiện lập trình mạng cho Microsoft Windows. WinSock tương thích với họ nghi thức mạngTCP/IP.Socket :Socket là đầu (endpoint) trao đổi dữ liệu giữa các quá trình, qua đó các ứng dụng WinSock gởi /nhận dữ liệu qua mạng.Hai loại Socket :Stream Socket :Dựa trên nghi thức TCP ( Tranmission Control Protocol ), việc truyền dữ liệu chỉ thực hiện giữahai quá trình đã thiết lập kết nối. Dữ liệu được truyền tin cậy, đúng trình tự và không lập lại.Dữ liệu được truyền như dòng liên tục các byte không phân biệt ranh giới các recordDatagram Socket :Dựa trên nghi thức UDP ( User Datagram Protocol ), việc truyền dữ liệu không yêu cầu có sựthiết lập kết nối giữa hai quá trình. Dữ liệu truyền không tin cậy, có thể không đúng trình tự hoặclập lại.Dữ liệu được truyền như dòng các record.Port :Port xác định duy nhất một quá trình trên một máy trong mạng.Một TCP/IP Socket gồm một địa chỉ IP kết hợp với một port ? xác định duy nhất một quá trìnhtrên mạng.Một số port dành riêng :UDP Ports :0 Reversed7 Echo37 Time42 Name Server53 Domain Name Server69 Trivial File Transfer Program ( TFTP )514 System Log..........TCP Ports :0 Reversed1 TCP Multiplexor20 FTP_ Data Connection21 FTP_ Command Connection23 TELNET25 SMTP42 Name Server53 Domain Name Server79 Finger_ find a active user.....................Lập trình winsockCác file cần thiết :WINSOCK.DLL hay WSOCK32.DLL ( tuỳ version 16 hay 32 bit của Windows ).WINSOCK.LIB hay WSOCK32.LIB.WINSOCK.H.Giới thiệu một số hàm của WinSock:Dưới đây chỉ giới thiệu chức năng của một số hàm WinSock, không trình bày prototype của cáchàmCác hàm khởi động WinSock :Dùng để khởi đầu và kết thúc quá trình sử dụng WinSock.WSAStartup() : Khởi động WinSock.WSACleanup() : Kết htúc WinSock.WSAGetLastError() : Lấy mã sai vừa xảy ra.Các hàm Socket :Dùng để thiết lập quá trình trao đổi dữ liệu trên mạng.socket() : tạo socket truyền dữ liệu.bind() : định danh cho socket vừa tạo (gán port cho socket).listen() : lắng nghe kết nối.accept() : chấp nhận kết nối từ client.connect() : kết nối với server.send(), recv() : gởi, nhận dữ liệu với stream socket.sendto(), recvfrom() : gởi, nhận dữ liệu với datagram socket.........Các hàm khác :inet_addr() : chuyển từ địa chỉ IP dạng số thập phân có chấm sang địa chỉ internet.inet_ntoa() : ngược lại.gethostname() : cho tên máy hiện hành.gethostbyname(),WSAAsyncGetHostByName(): cho địa chỉ IP ứng với tên máy.gethostbyaddr(),WSAAsyncGetHostByAddr(): cho tên máy ứng với địa chỉ IP.........WinSock error:Lỗi khi send dataWSANOTINITIALISED A successful AfxSocketInit must occur before using this API.WSAENETDOWN The Windows Sockets implementation detected that the network subsystemfailed.WSAEACCES The requested address is a broadcast address, but the appropriate flag was notset.WSAEINPROGRESS A blocking Windows Sockets operation is in progress.WSAEFAULT The lpBuf or lpSockAddr parameters are not part of the user address space, or thelpSockAddr argument is too small (less than the size of a SOCKADDR structure).WSAENETRESET The connection must be reset because the Windows Sockets implementationdropped it.WSAENOBUFS The Windows Sockets implementation reports a buffer deadlock.WSAENOTCONN The socket is not connected (SOCK_STREAM only).WSAENOTSOCK The descriptor is not a socket.WSAEOPNOTSUPP MSG_OOB was specified, but the socket is not of type SOCK_STREAM.WSAESHUTDOWN The socket has been shut down; it is not possible to call SendTo on a socketafter ShutDown has been invoked with nHow set to 1 or 2.WSAEWOULDBLOCK The socket is marked as nonblocking and the requested operation wouldblock.WSAEMSGSIZE The socket is of type SOCK_DGRAM, and the datagram is larger than themaximum supported by the Windows Sockets implementation.WSAECONNABORTED The virtual circuit was aborted due to timeout or other failure.WSAECONNRESET The virtual circuit was reset by the remote side.WSAEADDRNOTAVAIL The specified address is not available from the local machine.WSAEAFNOSUPPORT Addresses in the specified family cannot be used with this socket.WSAEDESTADDRREQ A destination address is required.WSAENETUNREACH The network cannot be reached from this host at this time.Lỗi khi receive dataWSANOTINITIALISED A successful AfxSocketInit must occur before using this API.WSAENETDOWN The Windows Sockets implementation detected that the network subsystemfailed.WSAENOTCONN The socket is not connected.WSAEINPROGRESS A blocking Windows Sockets operation is in progress.WSAENOTSOCK The descriptor is not a socket.WSAEOPNOTSUPP M ...
Tìm kiếm theo từ khóa liên quan:
thủ thuật máy tính công nghệ thông tin tin học quản trị mạng computer networkGợi ý tài liệu liên quan:
-
52 trang 430 1 0
-
24 trang 355 1 0
-
Top 10 mẹo 'đơn giản nhưng hữu ích' trong nhiếp ảnh
11 trang 314 0 0 -
Làm việc với Read Only Domain Controllers
20 trang 303 0 0 -
74 trang 299 0 0
-
96 trang 293 0 0
-
Báo cáo thực tập thực tế: Nghiên cứu và xây dựng website bằng Wordpress
24 trang 289 0 0 -
Đồ án tốt nghiệp: Xây dựng ứng dụng di động android quản lý khách hàng cắt tóc
81 trang 281 0 0 -
EBay - Internet và câu chuyện thần kỳ: Phần 1
143 trang 275 0 0 -
Tài liệu dạy học môn Tin học trong chương trình đào tạo trình độ cao đẳng
348 trang 269 1 0