|
|
1.1 root 1: Sample: Demonstration of the Windows Sockets API
2:
3: Summary:
4:
5: The WSOCK sample demonstrates the basics of sockets programming,
6: specifically for Windows Sockets. It demonstrates how to accept
7: incoming connections (via the Windows Sockets Asynchronous Extension
8: APIs, threads, and traditional BSD-style blocking calls) and how to
9: connect to remote hosts. Once connected, the user can send a text
10: string to the remote host. WSOCK also allows the user to view
11: information on a user-entered host name.
12:
13: More Information:
14:
15: For the program to operate correctly, the TCP/IP protocol must be
16: properly installed. Also, if two machines are used over a network,
17: both machines must have a "HOSTS" text file (for Windows NT machines,
18: this file is located in %SYSTEMROOT%\SYSTEM32\DRIVERS\ETC\HOSTS; if
19: TCP/IP is installed onto a Windows for Workgroups machine, the HOSTS
20: file is located in C:/WINDOWS/HOSTS). Within each HOSTS file, both the
21: remote and local addresses of both machines must be listed.
22:
23: WSOCK can run on a single machine (execute two copies of WSOCK) or
24: over a network with two Win32 machines. The following example explains
25: how two separate machines over a network would test WSOCK:
26:
27: 1. Machine "Bob" executes a copy of WSOCK.
28:
29: 2. Machine "Fred" executes a copy of WSOCK.
30:
31: 3. Machine "Bob" chooses one of the Listen menu options (under
32: WinSock) [Listen (Blocking), Listen With Threads, or Async Listen].
33:
34: 4. Machine "Fred" selects the Connect menu option (under WinSock).
35:
36: 5. Machine "Bob" enters "12" as a TCP port number.
37:
38: 6. Machine "Bob" waits for a connection.
39:
40: 7. Machine "Fred" enters "Bob" as the host name to connect to.
41:
42: 8. Machine "Fred" enters "12" as a TCP port number.
43:
44: Both machines are now connected and can send strings back and forth by
45: using the WinSock Send Message menu option.
46:
47: If "Bob" exits WSOCK while there is a connection, "Fred" will receive
48: a message box notification.
49:
50: Windows Sockets calls used:
51:
52: accept
53: closesocket
54: connect
55: gethostbyname
56: getservbyname
57: htons
58: listen
59: send
60: recv
61: WSAAsyncSelect
62: WSACleanup
63: WSAStartup
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.