Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
TCP/IP Sockets in C: Practical Guide for Programmers Winsock Adaptations of Example Code Below is the example source code from "TCP/IP Sockets in C: Practical Guide for Programmers" by Michael J. Donahoo and Kenneth L. Calvert modified for use with WinSock. This book can be ordered at your favorite local bookstore or online. Official Book Website The code below demonstrates the minimal number of changes required to make the examples from the text execute under Winsock. Further changes can be made to make this code more Winsock complaint (e.g., test socket() failure return value as SOCKET_ERROR rather than < 0). If you want some details/justifications for the adaptations of the examples to Winsock, see Transitioning from UNIX to Windows Socket Programming by Paul O'Steen WinSock Example code: TCPEchoClientWS.c DieWithErrorWS.c TCPEchoServerWS.c HandleTCPClientWS.c UDPEchoClientWS.c UDPEchoServerWS.c SigAction.c - Not Available (Signals are not available under Windows) UDPEchoServer-SIGIO.c - Not Available (Signals are not available under Windows) UDPEchoClient-Timeout.c - Not Available (Signals are not available under Windows) TCPEchoServer-Fork.c - Not Available (Win32 CreateProcess requires a separate executable) TCPEchoServerWS.h CreateTCPServerSocketWS.c AcceptTCPConnectionWS.c TCPEchoServer-ThreadWS.c (You can use the original TCPEchoServer-Thread.c under Windows if you also download a PThreads library for Windows. See http://sources.redhat.com/pthreads-win32.) TCPEchoServer-ForkN.c - Not Available (Win32 CreateProcess requires a separate executable) TCPEchoServer-SelectWS.c BroadcastSenderWS.c BroadcastReceiverWS.c BroadcastReceiverNonblockingWS.c (Added to show nonblocking WinSock socket since SIGIO example does not work) MulticastSenderWS.c MulticastReceiverWS.c ResolveNameWS.c ResolveServiceWS.c To compile: Make sure you add wsock32.lib to library module list Warning for users of older variants of Windows (NT and 98 or before): Some older versions of Windows require that you call bind( ) before any call to setsockopt( ). If setsockopt( ) fails, try adding a bind to address INADDR_ANY and to port 0 before the call to setsockopt( ). This should only apply to MulticastSenderWS.c and BroadcastSenderWS.c. Other Resources Winsock Tutorial from Willis Marti (Texas A&M) Transitioning from UNIX to Windows Socket Programming by Paul O'Steen