Windows Socket: Course: COMP6120 - Network Programming Year: 2016
Windows Socket: Course: COMP6120 - Network Programming Year: 2016
Windows Socket: Course: COMP6120 - Network Programming Year: 2016
Year : 2016
Windows Socket
Session 11
Learning Outcome
• What is Socket ?
• What is Winsock ?
• The Socket History
• Winsock History
• Supported Programming Models
• Elements of Winsock Programming
• General Program Flow
• Iterative Server pada Windows
• Concurrent Server pada Windows
WinSock
• What is Socket?
– Socket is is a programming model originally designed for
network programming under UNIX operating systems.
• What is Winsock?
– Winsock stands for Windows Socket;
– An Application Programming Interface for network
programming under the Microsoft Windows operating
systems.
– It is modeled after UNIX Socket but with platform-specific
features added.
WinSock
WinSock
WinSock
WinSock
• Asynchronous Model
– Makes use of non-blocking-mode I/O function calls.
• What is Non-Blocking I/O?
– Guaranteed function will return immediately:
– The calling code has to check if the function has completed before
return.
– If not, the calling code will have to handle that itself.(e.g. check at a
later time, call the function again, wait for asynchronous event to
trigger, etc.)
Elements of
Winsock Programming
Elements of
Winsock Programming
• BSD-Style Winsock Functions
– Core functions
• accept, bind, closesocket, connect, listen, recv,
recvfrom, select, send, sendto, Shutdown,
socket
– Auxiliary functions
• Getpeername, Getsockname, Getsockopt,
ioctlsocket
– Utility functions
• htonl, htons, inet_addr, inet_ntoa, ntohl, ntohs
Elements of
Winsock Programming
• Windows-Specific Winsock Functions
– Core functions
• WSAStartup, WSACleanup, WSAAsyncGettByn,
WSAAsyncSelect, WSACancelAsyncRequest,
WSAConnect,WSAIoctl, WSARecv, WSARecvFrom, WSASend,
WSASendTo, WSASocket
– Auxiliary functions
• WSADuplicateSocket, WSAEnumNetworkEvents,
WSAEnumProtocols, WSAGetLastError, WSAGetQOSByName,
WSAHtonl, WSAHtons, WSAJoinLeaf, WSANtohl, WSANtohs,
WSAProviderConfigChange, WSASetLastError
– Supporting functions
• WSACloseEvent, WSACreateEvent, WSAEventSelect,
WSAGetOverlappedResult, WSAResetEvent, WSASetEvent,
WSAWaitForMultipleEvents
General Program Flow
General Program Flow
General Program Flow
Iterative Server
Concurrent Server
Concurrent Server