📄 3-4.html
字号:
<P ALIGN="JUSTIFY">STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU</P>
<P ALIGN="JUSTIFY">BEGIN</P>
<P ALIGN="JUSTIFY">	CONTROL " send/recv \nBuffer &length", -1, "STATIC", SS_LEFT | WS_GROUP, 84, 8, 48, 20</P>
<P ALIGN="JUSTIFY">	CONTROL "&Port number", -1, "STATIC", SS_LEFT | WS_GROUP, 84, 31, 48, 10</P>
<P ALIGN="JUSTIFY">	CONTROL "&Blocking", IDS_BLOCK, "BUTTON", BS_AUTOCHECKBOX | WS_TABSTOP, 100, 61, 56, 12</P>
<P ALIGN="JUSTIFY">	CONTROL "&TCP", IDS_TCP, "BUTTON", BS_AUTOCHECKBOX | WS_TABSTOP, 20, 60, 41, 12</P>
<P ALIGN="JUSTIFY">	CONTROL "&Client", IDS_CLIENT, "BUTTON", BS_AUTOCHECKBOX | WS_TABSTOP, 19, 15, 35, 12</P>
<P ALIGN="JUSTIFY">	CONTROL "&Server", IDS_SERVER, "BUTTON", BS_AUTOCHECKBOX | WS_TABSTOP, 19, 26, 35, 12</P>
<P ALIGN="JUSTIFY">	CONTROL "&UDP", IDS_UDP, "BUTTON", BS_AUTOCHECKBOX | WS_TABSTOP, 20, 72, 41, 12</P>
<P ALIGN="JUSTIFY">	CONTROL "&Nonblocking", IDS_NOBLOCK, "BUTTON", BS_AUTOCHECKBOX | WS_TABSTOP, 100, 73, 56, 12</P>
</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3><P ALIGN="JUSTIFY">	</FONT><FONT SIZE=3>CONTROL "O.K.", IDOK, "BUTTON", BS_PUSHBUTTON | WS_TABSTOP, 40, 95, 37, 14</P>
</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3><P ALIGN="JUSTIFY">	</FONT><FONT SIZE=3>CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_TABSTOP, 90, 95, 37, 14</P>
<P ALIGN="JUSTIFY">	CONTROL "", IDS_BUFFLEN, "EDIT", ES_CENTER | WS_BORDER | WS_TABSTOP, 130, 11, 36, 12</P>
<P ALIGN="JUSTIFY">	CONTROL "", IDS_PORTNO, "EDIT", ES_CENTER | WS_BORDER | WS_TABSTOP, 130, 29, 36, 12</P>
<P ALIGN="JUSTIFY">	CONTROL "Protocol", 237, "button", BS_GROUPBOX, 6, 49, 70, 38</P>
<P ALIGN="JUSTIFY">	CONTROL "I/O Mode", 239, "button", BS_GROUPBOX, 90, 49, 70, 38</P>
<P ALIGN="JUSTIFY">	CONTROL "Program Mode", 241, "button", BS_GROUPBOX, 6, 7, 70, 34</P>
<P ALIGN="JUSTIFY">END</P>
</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3><P ALIGN="JUSTIFY"></P>
</FONT><FONT SIZE=3><P ALIGN="JUSTIFY">MainDialog DIALOG 17, 32, 163, 135</P>
<P ALIGN="JUSTIFY">CAPTION "Windows Shout"</P>
<P ALIGN="JUSTIFY">MENU MainMenu</P>
<P ALIGN="JUSTIFY">STYLE DS_ABSALIGN | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX</P>
<P ALIGN="JUSTIFY">BEGIN</P>
</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3><P ALIGN="JUSTIFY">	</FONT><FONT SIZE=3>CONTROL "", IDD_HNAME, "EDIT", ES_CENTER | WS_BORDER | WS_GROUP | WS_TABSTOP, 62, 9, 93, 12</P>
<P ALIGN="JUSTIFY">	CONTROL "", IDD_WRITE, "STATIC", SS_CENTER | SS_NOPREFIX | WS_BORDER, 7, 95, 45, 11</P>
</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3><P ALIGN="JUSTIFY">	</FONT><FONT SIZE=3>CONTROL "", IDD_SENT, "STATIC", SS_CENTER | WS_BORDER, 59, 95, 45, 11</P>
<P ALIGN="JUSTIFY">	CONTROL "", IDD_TIME, "STATIC", SS_CENTER | WS_BORDER, 111, 95, 45, 11</P>
</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3><P ALIGN="JUSTIFY">	</FONT><FONT SIZE=3>CONTROL "", IDD_WRITES, "STATIC", SS_CENTER | WS_BORDER, 7, 120, 45, 11</P>
<P ALIGN="JUSTIFY">	CONTROL "", IDD_BYTES, "STATIC", SS_CENTER | WS_BORDER, 59, 120, 45, 11</P>
</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3><P ALIGN="JUSTIFY">	</FONT><FONT SIZE=3>CONTROL "", IDD_BITS, "STATIC", SS_CENTER | WS_BORDER, 111, 120, 45, 11</P>
<P ALIGN="JUSTIFY">	CONTROL "writes[reads]", 105, "STATIC", SS_CENTER | WS_GROUP, 3, 85, 52, 9</P>
</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3><P ALIGN="JUSTIFY">	</FONT><FONT SIZE=3>CONTROL "writes[reads]/s", 105, "STATIC", SS_CENTER | WS_GROUP, 3, 111, 55, 9</P>
<P ALIGN="JUSTIFY">	CONTROL "bytes", 105, "STATIC", SS_CENTER | WS_GROUP, 61, 85, 42, 9</P>
<P ALIGN="JUSTIFY">	CONTROL "bytes/sec", 105, "STATIC", SS_CENTER | WS_GROUP, 61, 111, 42, 9</P>
<P ALIGN="JUSTIFY">	CONTROL "time (sec)", 105, "STATIC", SS_CENTER | WS_GROUP, 111, 85, 45, 9</P>
<P ALIGN="JUSTIFY">	CONTROL "bits/sec", 105, "STATIC", SS_CENTER | WS_GROUP, 113, 111, 42, 9</P>
<P ALIGN="JUSTIFY">	CONTROL "Host", IDD_COHOST, "STATIC", SS_LEFT, 7, 10, 52, 10</P>
<P ALIGN="JUSTIFY">	CONTROL "", IDD_COMMENT, "STATIC", SS_CENTER | WS_BORDER | WS_GROUP, 9, 68, 146, 11</P>
<P ALIGN="JUSTIFY">	CONTROL "&Start", IDOK, "BUTTON", BS_PUSHBUTTON | WS_TABSTOP, 6, 32, 32, 20</P>
<P ALIGN="JUSTIFY">	CONTROL "Sto&p", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_TABSTOP, 65, 32, 32, 20</P>
<P ALIGN="JUSTIFY">	CONTROL "E&xit", IDM_EXIT, "BUTTON", BS_PUSHBUTTON | WS_TABSTOP, 125, 32, 32, 20</P>
<P ALIGN="JUSTIFY">	CONTROL "", -1, "static", SS_BLACKFRAME, 0, 60, 163, 1</P>
<P ALIGN="JUSTIFY">END</P>
</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3><P ALIGN="JUSTIFY"></P>
</FONT><FONT SIZE=3><P ALIGN="JUSTIFY">SHOUT ICON wshout.ico</P>
</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3><P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY"> </P>
</FONT><FONT SIZE=3><P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * </FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3>错误描述字符串表</P>
</FONT><FONT SIZE=3><P ALIGN="JUSTIFY"> * </FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3>用于</FONT><FONT SIZE=3>WSAsperror()</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3>函数</P>
</FONT><FONT SIZE=3><P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY">STRINGTABLE</P>
<P ALIGN="JUSTIFY">BEGIN</P>
<P ALIGN="JUSTIFY"> WSABASEERR, "[0] No Error"</P>
<P ALIGN="JUSTIFY"> WSAEINTR, "[10004] Interrupted system call"</P>
<P ALIGN="JUSTIFY"> WSAEBADF, "[10009] Bad file number"</P>
<P ALIGN="JUSTIFY"> WSAEACCES, "[10013] Permission denied"</P>
<P ALIGN="JUSTIFY"> WSAEFAULT, "[10014] Bad address"</P>
<P ALIGN="JUSTIFY"> WSAEINVAL, "[10022] Invalid argument"</P>
<P ALIGN="JUSTIFY"> WSAEMFILE, "[10024] Too many open files"</P>
<P ALIGN="JUSTIFY"> WSAEWOULDBLOCK, "[10035] Operation would block"</P>
<P ALIGN="JUSTIFY"> WSAEINPROGRESS, "[10036] Operation now in progress"</P>
<P ALIGN="JUSTIFY"> WSAEALREADY, "[10037] Operation already in progress"</P>
<P ALIGN="JUSTIFY"> WSAENOTSOCK, "[10038] Socket operation on non-socket"</P>
<P ALIGN="JUSTIFY"> WSAEDESTADDRREQ, "[10039] Destination address required"</P>
<P ALIGN="JUSTIFY"> WSAEMSGSIZE, "[10040] Message too long"</P>
<P ALIGN="JUSTIFY"> WSAEPROTOTYPE, "[10041] Protocol wrong type for socket"</P>
<P ALIGN="JUSTIFY"> WSAENOPROTOOPT, "[10042] Bad protocol option"</P>
<P ALIGN="JUSTIFY"> WSAEPROTONOSUPPORT, "[10043] Protocol not supported"</P>
<P ALIGN="JUSTIFY"> WSAESOCKTNOSUPPORT, "[10044] Socket type not supported"</P>
<P ALIGN="JUSTIFY"> WSAEOPNOTSUPP, "[10045] Operation not supported on socket"</P>
<P ALIGN="JUSTIFY"> WSAEPFNOSUPPORT, "[10046] Protocol family not supported"</P>
<P ALIGN="JUSTIFY"> WSAEAFNOSUPPORT, "[10047] Address family not supported by protocol family"</P>
<P ALIGN="JUSTIFY"> WSAEADDRINUSE, "[10048] Address already in use"</P>
<P ALIGN="JUSTIFY"> WSAEADDRNOTAVAIL, "[10049] Can't assign requested address"</P>
<P ALIGN="JUSTIFY"> WSAENETDOWN, "[10050] Network is down"</P>
<P ALIGN="JUSTIFY"> WSAENETUNREACH, "[10051] Network is unreachable"</P>
<P ALIGN="JUSTIFY"> WSAENETRESET, "[10052] Net dropped connection or reset"</P>
<P ALIGN="JUSTIFY"> WSAECONNABORTED, "[10053] Software caused connection abort"</P>
<P ALIGN="JUSTIFY"> WSAECONNRESET, "[10054] Connection reset by peer"</P>
<P ALIGN="JUSTIFY"> WSAENOBUFS, "[10055] No buffer space available"</P>
<P ALIGN="JUSTIFY"> WSAEISCONN, "[10056] Socket is already connected"</P>
<P ALIGN="JUSTIFY"> WSAENOTCONN, "[10057] Socket is not connected"</P>
<P ALIGN="JUSTIFY"> WSAESHUTDOWN, "[10058] Can't send after socket shutdown"</P>
<P ALIGN="JUSTIFY"> WSAETOOMANYREFS, "[10059] Too many references, can't splice"</P>
<P ALIGN="JUSTIFY"> WSAETIMEDOUT, "[10060] Connection timed out"</P>
<P ALIGN="JUSTIFY"> WSAECONNREFUSED, "[10061] Connection refused"</P>
<P ALIGN="JUSTIFY"> WSAELOOP, "[10062] Too many levels of symbolic links"</P>
<P ALIGN="JUSTIFY"> WSAENAMETOOLONG, "[10063] File name too long"</P>
<P ALIGN="JUSTIFY"> WSAEHOSTDOWN, "[10064] Host is down"</P>
<P ALIGN="JUSTIFY"> WSAEHOSTUNREACH, "[10065] No Route to Host"</P>
<P ALIGN="JUSTIFY"> WSAENOTEMPTY, "[10066] Directory not empty"</P>
<P ALIGN="JUSTIFY"> WSAEPROCLIM, "[10067] Too many processes"</P>
<P ALIGN="JUSTIFY"> WSAEUSERS, "[10068] Too many users"</P>
<P ALIGN="JUSTIFY"> WSAEDQUOT, "[10069] Disc Quota Exceeded"</P>
<P ALIGN="JUSTIFY"> WSAESTALE, "[10070] Stale NFS file handle"</P>
<P ALIGN="JUSTIFY"> WSAEREMOTE, "[10071] Too many levels of remote in path"</P>
<P ALIGN="JUSTIFY"> WSASYSNOTREADY, "[10091] Network SubSystem is unavailable"</P>
<P ALIGN="JUSTIFY"> WSAVERNOTSUPPORTED, "[10092] WINSOCK DLL Version out of range"</P>
<P ALIGN="JUSTIFY"> WSANOTINITIALISED, "[10093] Successful WSASTARTUP not yet performed"</P>
<P ALIGN="JUSTIFY"> WSAHOST_NOT_FOUND, "[11001] Host not found"</P>
<P ALIGN="JUSTIFY"> WSATRY_AGAIN, "[11002] Non-Authoritative Host not found"</P>
<P ALIGN="JUSTIFY"> WSANO_RECOVERY, "[11003] Non-Recoverable errors: FORMERR, REFUSED, NOTIMP"</P>
<P ALIGN="JUSTIFY"> WSANO_DATA, "[11004] Valid name, no data record of requested </P>
<P ALIGN="JUSTIFY">type"</P>
<P ALIGN="JUSTIFY">END</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/* eof */</P>
<P ALIGN="JUSTIFY"> </P>
</FONT><B><FONT FACE="黑体" LANG="ZH-CN" SIZE=4><P><A NAME="_Toc336792894"><A NAME="_Toc336793370"></FONT><FONT FACE="Arial" SIZE=4>3.4.3.4 ushout.c</FONT><FONT FACE="黑体" LANG="ZH-CN" SIZE=4>清单</A></A></P>
</B></FONT><FONT SIZE=3><P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * </FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3>文件名</FONT><FONT SIZE=3>: USHOUT.C</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">#include "wshout.h"</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/* MSC Include files: */</P>
<P ALIGN="JUSTIFY">#include <stdio.h></P>
<P ALIGN="JUSTIFY">#include <io.h></P>
<P ALIGN="JUSTIFY">#include <string.h></P>
<P ALIGN="JUSTIFY">#include <stdlib.h></P>
<P ALIGN="JUSTIFY">#include <time.h></P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/* Returns the number of bytes written */</P>
<P ALIGN="JUSTIFY">long UWriteData(SOCKET hSock, HWND hOurDlg, int send_len) </P>
<P ALIGN="JUSTIFY">{</P>
<P ALIGN="JUSTIFY"> int counter;</P>
<P ALIGN="JUSTIFY"> static int DataBuffer[BUF_SIZE]; /* Buffer to hold generated data	*/</P>
<P ALIGN="JUSTIFY"> static char ReplyBuffer[512]; /* Buffer to hold any reply rcvd */</P>
<P ALIGN="JUSTIFY"> long bytes_sent = 0L;	 /* Counter of bytes on connection	*/</P>
<P ALIGN="JUSTIFY"> long total_len = 1024L*1024L; /* Total # of bytes to generate	*/</P>
<P ALIGN="JUSTIFY"> time_t start, end;		 /* variables to hold read timing	*/</P>
<P ALIGN="JUSTIFY"> long total_time = 0L;	 /* variable to hold delta t	*/</P>
<P ALIGN="JUSTIFY"> long write_count = 0L;	 /* number of times		*/</P>
<P ALIGN="JUSTIFY"> long tmp = 0L;		 /* holds count for bytes written	*/</P>
<P ALIGN="JUSTIFY"> long ltemp = 0L;</P>
<P ALIGN="JUSTIFY"> int i_temp;</P>
<P ALIGN="JUSTIFY"> extern int run_cancelled;</P>
<P ALIGN="JUSTIFY"> </P>
<P ALIGN="JUSTIFY"> struct	sockaddr_in dest; /* Destination machine address structure */</P>
<P ALIGN="JUSTIFY"> </P>
<P ALIGN="JUSTIFY"> /* What makes shout unique is that it generates data*</P>
<P ALIGN="JUSTIFY"> * in memory (as opposed to accessing the disk).	*</P>
<P ALIGN="JUSTIFY"> * This tests the 'raw' speed of the TCP connection	*</P>
<P ALIGN="JUSTIFY"> * as the rate-limiting access time is eliminated.	*</P>
<P ALIGN="JUSTIFY"> * First, generate the data and place it into an	*</P>
<P ALIGN="JUSTIFY"> * array, data_buffer:				*/</P>
<P ALIGN="JUSTIFY"> </P>
<P ALIGN="JUSTIFY"> for (counter = 0; counter < BUF_SIZE; counter++)</P>
<P ALIGN="JUSTIFY">	DataBuffer[counter] = counter;</P>
<P ALIGN="JUSTIFY"> </P>
<P ALIGN="JUSTIFY"> /* Write data on the descriptor like a banshee,</P>
<P ALIGN="JUSTIFY"> * careful to time the writes and count data</P>
<P ALIGN="JUSTIFY"> * transmitted:</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY"> </P>
<P ALIGN="JUSTIFY"> SetDlgItemText(hOurDlg, IDD_COMMENT, "Sending UDP Data ...");</P>
<P ALIGN="JUSTIFY"> time( &start );	</P>
<P ALIGN="JUSTIFY"> while (bytes_sent < total_len){/* while still bytes to send */</P>
<P ALIGN="JUSTIFY">	do {</P>
<P ALIGN="JUSTIFY">	 ;</P>
<P ALIGN="JUSTIFY">	} while (ShoutBlockingHook()); /* Dispatch messages if any */</P>
<P ALIGN="JUSTIFY">	</P>
<P ALIGN="JUSTIFY">	if (run_cancelled) {</P>
<P ALIGN="JUSTIFY">	 WSASetLastError(WSAEINTR);</P>
<P ALIGN="JUSTIFY">	 break;	/* Non-blocking mode was cancelled */</P>
<P ALIGN="JUSTIFY">	}</P>
<P ALIGN="JUSTIFY">	 </P>
<P ALIGN="JUSTIFY">	tmp = send(hSock, (char FAR *) &DataBuffer, send_len, 0);</P>
<P ALIGN="JUSTIFY">	if (tmp == SOCKET_ERROR) {</P>
<P ALIGN="JUSTIFY">	 if (h_errno == WSAEWOULDBLOCK) /* if no data, read again */</P>
<P ALIGN="JUSTIFY">		continue;</P>
<P ALIGN="JUSTIFY">	 else {</P>
<P ALIGN="JUSTIFY">		wshout_err (hOurDlg, WSAGetLastError(), "send()");</P>
<P ALIGN="JUSTIFY">	 }</P>
<P ALIGN="JUSTIFY">	 </P>
<P ALIGN="JUSTIFY">	 /* Calc. time elapsed & stats about any data sent */</P>
<P ALIGN="JUSTIFY">	 time(&end);</P>
<P ALIGN="JUSTIFY">	 if (total_time = (long) difftime(end, start)) {</P>
<P ALIGN="JUSTIFY">		/* Print the statistics gathered */</P>
<P ALIGN="JUSTIFY">		wsprintf((LPSTR)prbuf,"%ld\n",write_count);</P>
<P ALIGN="JUSTIFY">		SetDlgItemText(hOurDlg, IDD_WRITE, (LPSTR) prbuf);</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">		wsprintf((LPSTR)prbuf,"%ld\n",bytes_sent)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -