sudo docker pull thinkhy/cs162-pintos
Due: 7 July 2015
For the first checkpoint, the following code features will be due �
15-440 Project 0 Project 0: Implementing a multi-client echo server Due Thursday, January 30, 2014 at 11:59pm The goal of this assignment is to get up to speed on the Go programming language and to help remind you about the basics of socket programming that you learned in 15-213. In this assignment you will implement a simple multi-client echo server in Go: every message sent by a client should be echoed to all connected clients. Server Characteristics Your multi-client echo server must have the following characteristics:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub getTime | |
{ | |
my $time = shift || time(); | |
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); | |
$year += 1900; | |
$mon ++; | |
$min = '0'.$min if length($min) < 2; | |
$sec = '0'.$sec if length($sec) < 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void WriteLog(CString strLog) | |
{ | |
EnterCriticalSection(g_cs); | |
static CString strFileName; | |
if (strFileName.IsEmpty()) | |
{ | |
strFileName.GetBuffer(MAX_PATH); | |
::GetModuleFileName(NULL, strFileName.GetBuffer(0), MAX_PATH); | |
::PathRemoveFileSpec(strFileName.GetBuffer(0)); | |
::PathAppend(strFileName.GetBuffer(0), L"Log.txt"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CMainFrame::DrawView(HBITMAP hbmp) | |
{ | |
ASSERT(hbmp != NULL); | |
CView *pView = GetActiveView(); | |
ASSERT(pView != NULL); | |
// pView->Invalidate(TRUE); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "apue.h" | |
ssize_t /* Read "n" bytes from a descriptor */ | |
readn(int fd, void *ptr, size_t n) | |
{ | |
size_t nleft; | |
ssize_t nread; | |
nleft = n; | |
while (nleft > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://topic.csdn.net/u/20080414/14/7e4737fe-53c5-443a-b38a-7735c423e4aa.html | |
对于send函数: | |
send函数只负责将数据提交给协议层。 | |
当调用该函数时,send先比较待发送数据的长度len和套接字s的发送缓冲区的长度,如果len大于s的发送缓冲区的长度,该函数返回SOCKET_ERROR; | |
如果len小于或者等于s的发送缓冲区的长度,那么send先检查协议是否正在发送s的发送缓冲中的数据; | |
如果是就等待协议把数据发送完,如果协议还没有开始发送s的发送缓冲中的数据或者s的发送缓冲中没有数据,那么send就比较s的发送缓冲区的剩余空间和len; | |
如果len大于剩余空间大小,send就一直等待协议把s的发送缓冲中的数据发送完,如果len小于剩余空间大小,send就仅仅把buf中的数据copy到剩余空间里(注意并不是send把s的发送缓冲中的数据传到连接的另一端的,而是协议传的,send仅仅是把buf中的数据copy到s的发送缓冲区的剩余空间里)。 | |
如果send函数copy数据成功,就返回实际copy的字节数,如果send在copy数据时出现错误,那么send就返回SOCKET_ERROR; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma comment(lib, "winmm.lib") | |
// call example | |
// 支持绝对路径和相对路径 | |
::PlaySound(strSoundFile.c_str(), NULL, SND_ASYNC|SND_NOWAIT|SND_FILENAME); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma comment(lib, "winmm.lib") | |
// call example | |
// 支持绝对路径和相对路径 | |
::PlaySound(strSoundFile.c_str(), NULL, SND_ASYNC|SND_NOWAIT|SND_FILENAME); |