首页 > 其他 > 详细

大学生活阶段性总结

时间:2015-12-29 19:03:49      阅读:677      评论:0      收藏:0      [点我收藏+]

 我是一个地道的农村人,后来考入一所本科大学,选了计算机专业,这个让我又爱又恨的专业。刚开始因为家庭经济等原因,对计算机的了解基本为零。打字不会不说,啥是主板,硬盘,啥是软件都不懂。大脑完全是真空的。大一的时候计算机操作可真心让我泪流满面啊,当然基于我的好问,我的老师们也对我苦笑不得,啥都不会,“我教书那么多年还没有遇到过底子这么差的”。

  基本没有底子的我要想学好这个专业真下了苦功夫,我的大学基本是在图书馆里度过的,暑假。寒假也是抱着书回家啃的,不过我动手能力是在太弱,也就学得马马虎虎,从图书馆里借出来的书倒真不算少,200多本,真正看完的却也没几本,那时候没有方向,啥都学,啥都会一点,刚开始我要学的就是打字,我学了好几月才真正学会,确确实实是一只笨鸟。后来就学OFFICE,也就学得很一般,勉强会用而已。大二的时候自学C++,MFC,PS等的,学完数据结构就做了两个小游戏俄罗斯方块和坦克大战。先说说这两个小游戏吧,首先上效果图

技术分享

技术分享

 除了第一个游戏的界面设计是参照别人的外,画图,设计,编码都是我自己做了。

 好了,现在上坦克大战的源代码,俄罗斯方块就不上了,网上有很多的,才学了两年,写得代码确实烂,希望各位多给给意见,在此谢过了。

  

 1 #pragma once
 2 #include "afxwin.h"
 3 #include<vector>
 4 #include<random>
 5 #include<array>
 6 class CGame :public CWnd
 7 {
 8 public:
 9     CGame();
10     //考虑到未来很可能会有增强版的坦克大战,所以把它声明为virtual
11     virtual ~CGame();
12 private:  //所需的各种图片
13     CBitmap m_map;
14     CBitmap m_phero;
15     CBitmap m_penemy;
16     CBitmap m_pbrick;
17     CBitmap m_pexplode;
18     CBitmap m_pbullet;
19     CBitmap m_pdead;
20     CBitmap m_enemy_bullet;
21 private:  //所需的各种自定义类型
22     enum direction{ right = 0, down = 1, left = 2, up = 3 };
23     struct Bullet{
24         direction m_direction = up;
25         CPoint m_position = { 0, 0 };
26     };
27 private:
28     CPoint m_hero_point = { 1080, 0 };      //游戏刚开始我的位置
29     std::array<Bullet, 50> m_bullet;       //我的子弹
30     size_t m_insert = 0;                //我的新子弹插入到数组的位置
31     direction m_direction = right;   //我的方向
32 
33     std::array<Bullet, 100> enemy_bullet;  //敌人的子弹
34     size_t enemy_insert = 0;         //敌人新的子弹插入到数组的位置
35     std::vector<CPoint> enemy_position{ 15, {-120,-120} }; //敌人的位置
36     std::vector<direction> enemy_direction{15,up};  //敌人的方向
37     bool enemy_broken = false;     //敌人是否死亡
38     bool enemy_disapper = false;   //是否让敌人消失
39     CRect disapper_rect;
40     size_t dead_num = 0;            //敌人死亡人数
41     CRect broken_rect;           //敌人死亡范围
42     size_t  enemy_num = 5;      //敌人的数量
43 
44     std::vector<CRect> timer_disapper{20};    //表示某个定时器发送重绘的区域
45     bool m_is_start = false;           //游戏是否开始
46     bool m_game_over = false;         //游戏是否结束
47     bool m_timer = false;             //是否设置了定时器
48     bool m_upgrade = false;          //是否需要升级
49     bool m_new=false;                      //是不是正在进行初始化 
50     size_t m_timer_id = 2;
51     size_t m_degree = 1;                      //游戏的难度
52     std::vector<CPoint>  m_main_map{37};//由墙组成的地图
53     std::random_device m_rand;   //随机数生成器
54 private:
55     bool isHit(const CPoint& point)const;
56     bool isOverlap(const CPoint& pont1,const CPoint& point2)const;
57     std::pair<bool, CRect> isBroken()const;
58     void startGame();
59     void enemyBulletMove(); 
60     void myBulletMove();
61     void enemyMove();
62 public:
63     DECLARE_MESSAGE_MAP()
64     afx_msg void OnPaint();
65     afx_msg void OnTimer(UINT_PTR nIDEvent);
66     virtual BOOL PreTranslateMessage(MSG* pMsg);
67     afx_msg void OnDestroy();
68 };
 1 //我的子弹的移动
 2 void CGame::myBulletMove()
 3 {
 4     for (size_t i = 0; i < 50; ++i){
 5         if (m_bullet[i].m_position.x != -10){  //含有子弹
 6             //擦除原来的子弹
 7             CRect rect{ m_bullet[i].m_position.x, m_bullet[i].m_position.y,
 8                 m_bullet[i].m_position.x + 10, m_bullet[i].m_position.y + 10 };
 9             InvalidateRect(rect);
10             //子弹移动
11             switch (m_bullet[i].m_direction){
12             case up:
13                 m_bullet[i].m_position.y -= 40;
14                 break;
15             case down:
16                 m_bullet[i].m_position.y += 40;
17                 break;
18             case left:
19                 m_bullet[i].m_position.x -= 40;
20                 break;
21             case right:
22                 m_bullet[i].m_position.x += 40;
23             }
24             CPoint &temp = m_bullet[i].m_position;
25             //如果打到左墙或者右墙则消失
26             if (temp.x < 40 ||    
27                 temp.x>1190){
28                 temp.x = -10;
29                 temp.y = -10;
30             }
31             //如果打到上墙或者下墙则消失
32              if (temp.y < 40    
33                 || temp.y>710){
34                 temp.x = -10;
35                 temp.y = -10;
36             }
37             //看看是否打到敌人,如果打到敌人加入到被打爆的敌人数组下,并且将敌人移走
38              for (auto it = enemy_position.begin(); it != enemy_position.begin() + enemy_num;++it){
39                 if (temp.x >= it->x&&
40                     temp.x < it->x + 120 &&
41                     temp.y >=it->y&&
42                     temp.y < it->y + 120)
43                 {
44                     rect.left = it->x;
45                     rect.right = it->x + 120;
46                     rect.top = it->y;
47                     rect.bottom = it->y + 120;
48                     broken_rect = rect;
49                     it->x = -200;
50                     it->y = -200;
51                     enemy_broken = true;
52                     InvalidateRect(broken_rect);
53                     temp.x = -10;
54                     temp.y = -10;
55                     break;
56                 }
57             }
58             //如果打到地图上
59             for (const auto& it : m_main_map){
60                 if (temp.x >= it.x&&
61                     temp.x <it.x + 40 &&
62                     temp.y >=it.y&&
63                     temp.y < it.y + 40){
64                     temp.x = -10;
65                     temp.y = -10;
66                     break;
67                 }
68             }
69             //如果上述情况没有发生,画上新的子弹
70             if (temp.x != -10){
71                 rect.left = temp.x;
72                 rect.right = temp.x + 10;
73                 rect.top = temp.y;
74                 rect.bottom = temp.y + 10;
75                 InvalidateRect(rect);
76             }
77         }
78     }
79 }

 

   代码不能全部粘贴上去,需要的朋友可以找我拿。这个游戏比较简单,就不上所有的代码了吧。

   好,继续我的废话啊。大三开始学习计算机网络,我也学了一点网络编程知识,就写了一个聊天室程序,这次我可就不用窗体的了,专注于C++11语法和应用,写了一个多线程程序,后来学了网络编程加上了select版本的聊天程序。自己测试通过。图就没了,直接上代码吧。首先是客户端的代码,客户端支持脚本启动,如果没有脚本就会要求你输入IP和用户名,后来我写了一个脚本,启动了200个客户端连接服务器,再多一点windows就崩了。

 1 #ifndef TCPC_H
 2 #define TCPC_H
 3 #include<WinSock2.h>
 4 #include<iostream>
 5 #include<string>
 6 #include<thread>
 7 #include<mutex>
 8 #include<windows.h>
 9 #pragma comment(lib,"WS2_32.LIB")
10 class CursorControl{
11 public:
12     COORD pos;
13     HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
14     CONSOLE_SCREEN_BUFFER_INFO bInfo;
15 public:
16     CursorControl();
17     void changeLine(int y);
18     void changeRowTo(int x);
19     void setPose(int x, int y);
20     COORD getPostion();
21 };
22 
23 class Client{
24 private:
25     WSADATA wsa_data;            //用于填充套接字库版本的有关信息
26     SOCKET server_socket = NULL; //服务器套接字(用于同服务器IPv4地址绑定)
27     SOCKADDR_IN server_socket_addr;  //服务器的IPv4地址
28     const int port = 9999;                 //要链接服务器9999端口
29     CursorControl m_cursor; 
30     size_t now_line=0;                   //当前光标所在的行
31 public:
32     Client();
33     ~Client();
34     void setIpAddress(const std::string& address);
35     void sendData(const std::string& data)const;
36     std::string recvData()const;
37     void dealRecv();
38     void connectServer(); 
39     void deleteCurent();
40     void deletPreData();
41 };
42 
43 class ControlClientSengMessage{
44 private:
45     CursorControl m_cursor;
46     size_t now_line = 8;
47 public:
48     void sendMessage(const  Client& m_client);
49     void deletPreData();
50 };
51 #endif
  1 #include"TCPC.h"
  2 using std::cout;
  3 using std::endl;
  4 using std::cin;
  5 using std::string;
  6 std::mutex output_mutex;
  7 const int string_size = sizeof("please enter he meessage on below:");
  8 Client::Client()
  9 {
 10     //加载wincock 2.2版本
 11     if (WSAStartup(MAKEWORD(2, 2), &wsa_data) != 0){
 12         cout << "WSAStartup failed" << endl;
 13         return;
 14     }
 15     //创建套接字描述字
 16     if ((server_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET){
 17         cout << "creat serversocket failed with error" << " " << WSAGetLastError()
 18             << endl;
 19         return;
 20     }
 21 }
 22 
 23 
 24 
 25 Client::~Client() 
 26 {    
 27     cout << "调用析构函数!" << ::endl;
 28     closesocket(server_socket);
 29     WSACleanup();    
 30 }
 31 
 32 void Client::deletPreData()
 33 {
 34     for (int i = 0; i < 8; ++i){
 35         m_cursor.setPose(0,i);
 36         for (int i = 0; i < 80; ++i)
 37             cout << " ";
 38     }
 39     now_line = 1;
 40     m_cursor.setPose(0,0);
 41 }
 42 
 43 void Client::setIpAddress(const string& address)
 44 {
 45     server_socket_addr.sin_family = AF_INET;
 46     server_socket_addr.sin_port = htons(port);
 47     server_socket_addr.sin_addr.s_addr = inet_addr(address.c_str());
 48 }
 49 
 50 void Client::connectServer()
 51 {
 52     if (connect(server_socket,
 53         (SOCKADDR *)&server_socket_addr, sizeof(server_socket_addr))
 54         == SOCKET_ERROR){
 55         cout << "connecting failed with error" << " " << WSAGetLastError() << endl;
 56     }
 57 }
 58 
 59 void  Client::deleteCurent()
 60 {
 61     m_cursor.changeRowTo(0);
 62     for (int i = 0; i < 80; ++i){
 63         cout << " ";
 64     }
 65     
 66 }
 67 
 68 void Client::dealRecv()
 69 {
 70     while (true){
 71         string data = recvData();
 72         output_mutex.lock();
 73         const COORD now_pos = m_cursor.getPostion();
 74         m_cursor.setPose(0, now_line++);
 75         if (now_line >= 8)
 76             deletPreData();
 77         cout << data;
 78         m_cursor.setPose(now_pos.X,now_pos.Y);
 79         output_mutex.unlock();
 80     }
 81 }
 82 
 83 string Client::recvData()const
 84 {
 85     const size_t array_len = 200;
 86     char buf[array_len];
 87     int buf_len = 0;
 88     do{
 89         buf_len = recv(server_socket, buf, array_len - 1, 0);
 90         if (buf_len <= 0){
 91             closesocket(server_socket);
 92             return "";
 93         }
 94         if (buf_len >= array_len - 1)
 95             buf[array_len - 1] = \0;
 96         else
 97             buf[buf_len] = \0;
 98     } while (buf_len >= array_len - 1);
 99     string str(buf);
100     return str;
101 }
102 
103 void Client::sendData(const string& data)const
104 {
105     int message_len;
106     if ((message_len = send(server_socket, data.c_str(),
107         strlen(data.c_str()), 0)) == INVALID_SOCKET){
108         cout << "send data failed with error" << " " << WSAGetLastError() << endl;
109     }
110 }
111 
112 CursorControl::CursorControl()
113 {
114     pos.X = 0;
115     pos.Y = 0;
116 //    hOut = GetHandle(_OUTPUT_HANDLE);
117 }
118 
119 void CursorControl::changeLine(int y)
120 {
121     pos.Y += y;
122     SetConsoleCursorPosition(hOut, pos);
123 }
124 
125 void CursorControl::changeRowTo(int x)
126 {
127     pos.X = x;
128     SetConsoleCursorPosition(hOut, pos);
129 }
130 
131 COORD CursorControl::getPostion()
132 {
133     GetConsoleScreenBufferInfo(hOut, &bInfo);
134     return bInfo.dwCursorPosition;
135 }
136 
137 void CursorControl::setPose(int x, int y)
138 {
139     pos.X = x;
140     pos.Y = y;
141     SetConsoleCursorPosition(hOut, pos);
142 
143 }
144 
145 void ControlClientSengMessage::deletPreData()
146 {
147     output_mutex.lock();
148     m_cursor.setPose(string_size, 10);
149     for (int i = string_size; i < 80; ++i)
150         cout << " ";
151     m_cursor.setPose(string_size, 10);          
152     output_mutex.unlock();
153 }
154 
155 void ControlClientSengMessage::sendMessage(const Client& m_client)
156 {
157     string send_data;
158     int message_len = 0;
159     output_mutex.lock();
160     m_cursor.setPose(0, 10);
161     ::cout << "please enter he meessage on below:";
162     output_mutex.unlock();
163     while (send_data != "exit"){
164         getline(cin, send_data);    
165         m_client.sendData(send_data);
166          deletPreData();
167     }
168 }
 1 #include"TCPC.h"
 2 void deleteContent()
 3 {
 4     CursorControl m_cursor;
 5     m_cursor.setPose(0, 0);
 6     for (int i = 0; i < 80; ++i)
 7         std::cout << " ";
 8     m_cursor.setPose(0, 1);
 9     for (int i = 0; i < 80; ++i)
10         std::cout << " ";
11     m_cursor.setPose(0, 8);
12 }
13 
14 void enterNameAndIp(std::string& user_name, std::string& ip)
15 {
16     std::cout << "please enter the ip of server:";
17     std::cin >> ip;
18     std::cout << "please enter the name of your:";
19     std::cin >> user_name;
20 }
21 
22 int main(int argc,char* argv[])
23 {
24     std::cout.sync_with_stdio();
25     std::string user_name, server_ip;
26     if (argc == 3)
27     {
28         user_name = argv[1];
29         server_ip = argv[2];
30     }
31     else
32     {
33         enterNameAndIp(user_name, server_ip);
34         deleteContent();
35     }
36 
37     Client client;
38     client.setIpAddress(server_ip);
39     client.connectServer();
40     client.sendData(user_name);
41 
42     ControlClientSengMessage send_way;
43     std::thread send_thread{[&](){send_way.sendMessage(client); }};
44     send_thread.detach();
45     std::thread   recv_thread{[&](){client.dealRecv(); }};
46     recv_thread.join();
47     return 0;
48 }

以下是启动脚本。

@echo off
for /l %%i in (1,1,10) do (start test.exe %%i 127.0.0.1 )

以下是关闭脚本

@echo off
tasklist /NH /FI "IMAGENAME eq test.exe" | find "test.exe"
if not ERRORLEVEL 1 (taskkill /f /im test.exe)
pause

我现在还不是很清楚脚本语言,照葫芦画瓢,反正能用就行。

好,现在上服务器代码,这个会有点意思,因为容错性还是蛮不错的,而且有两个版本。

1 #include"TCPS.h"
2 int main()
3 {
4     TcpServer m_server;
5     m_server.run();
6     return 0;
7 }
  1 #include"TCPS.h"
  2 //std::atomic<std::map<std::string, SOCKET>>  TcpServer::m_client;
  3 TcpServer::TcpServer()
  4 {
  5     initAddress();
  6     getReady();
  7 }
  8 
  9 void TcpServer::initAddress()
 10 {
 11     memset(&server_addr, 0, sizeof(server_addr));
 12     server_addr.sin_family = AF_INET;
 13     server_addr.sin_port = htons(port);
 14     server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
 15 }
 16 
 17 void TcpServer::getReady()
 18 {
 19     //加载2.2版本的winsock
 20     if (WSAStartup(MAKEWORD(2, 2), &wsa_data)!=0){
 21         std::cout << "WSAStartup failed" << std::endl;
 22         return;
 23     }
 24     //创建套接字描述字
 25     if ((m_listening_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET){
 26         std::cout << "create listensocket failed with error" << " " << WSAGetLastError() << std::endl;
 27         return;
 28     }
 29     //绑定套接字与地址信息
 30     if (bind(m_listening_socket, (SOCKADDR *)&server_addr, sizeof(server_addr)) == SOCKET_ERROR){
 31         std::cout << "bind failed with error " << WSAGetLastError() << std::endl;
 32         return;
 33     }
 34 }
 35 //多线程程序
 36 void TcpServer::run()
 37 {
 38     listenClient(); //监听客户端请求
 39     while (true){
 40         SOCKET new_connection= connectionClient(); //连接请求客户端
 41         std::string user_name = recvData(new_connection);
 42         loginPrompt(user_name,new_connection);//记录客户信息
 43         //启动一个线程负责客户通话
 44         (new std::thread(&TcpServer::dealClient,this,user_name,new_connection))->detach();
 45     }
 46 }
 47 
 48 /*
 49 //I/O复用程序
 50 void TcpServer::run()
 51 {
 52     fd_set listen_set, socket_set;
 53     int max_fd = 0;
 54     FD_ZERO(&socket_set);
 55     listenClient(); //监听客户端请求
 56     FD_SET(m_listening_socket, &socket_set);  //加入新的监听
 57     max_fd = max(m_listening_socket,0) + 1;
 58     while (true)
 59     {
 60 //        FD_ZERO(&socket_set);       //使用前必须清空套接字集合      
 61         listen_set = socket_set;
 62         int return_type = select(max_fd, &listen_set, NULL, NULL,NULL);
 63         if (return_type == SOCKET_ERROR)
 64         {
 65             return ;
 66         }
 67         if (FD_ISSET(m_listening_socket, &listen_set))  //有了新的连接
 68         {
 69             SOCKET new_connection = connectionClient();
 70             FD_SET(new_connection, &socket_set);
 71             max_fd = max(new_connection,max_fd) + 1;
 72             if (new_connection == INVALID_SOCKET)
 73             {
 74                 return;
 75             }
 76             std::string user_name = recvData(new_connection);
 77             loginPrompt(user_name, new_connection);//记录客户信息
 78         }
 79         //已有连接发来信息,则广播消息
 80         for (int i = 0; i < socket_set.fd_count; ++i)
 81         {
 82             if (socket_set.fd_array[i] != m_listening_socket &&
 83                 FD_ISSET(socket_set.fd_array[i], &listen_set))
 84             {
 85                 std::string message,recv_data;
 86                 auto it = m_client._My_val.find(socket_set.fd_array[i]);
 87                 if (it != m_client._My_val.end())
 88                 {
 89                     message += it->second;
 90                 }
 91                 else
 92                 {
 93                     std::cout << "not find the client " << std::endl;
 94                 }
 95                 recv_data = recvData(socket_set.fd_array[i]);
 96                 if (recv_data.empty())
 97                 {   
 98                     closesocket(socket_set.fd_array[i]);
 99                     FD_CLR(socket_set.fd_array[i],&socket_set);
100                     m_client._My_val.erase(it);
101                     message += " leave!";
102                 }
103                 else
104                 {
105                     message += " : ";
106                     message += recv_data;
107                 }
108                 sendData(message);
109             }
110         }
111     }
112 }
113 //本来打算用线程池来实现的,后来发现每个线程执行时间实在太长,所以就取消了
114 
115 void TcpServer::run()
116 {
117 
118 }
119 */
120 
121 void TcpServer::listenClient()
122 {
123     if (listen(m_listening_socket, 100) == SOCKET_ERROR){
124         std::cout << "listen failed with error " << WSAGetLastError() << std::endl;
125         return ;
126     }
127 }
128 
129 SOCKET TcpServer::connectionClient()
130 {
131     SOCKET new_connection;
132     SOCKADDR_IN client_addr;        //connect方IPv4地址
133     int client_addr_len = sizeof(client_addr);     //conect方IPv4地址的长度
134     std::cout << client_addr_len << std::endl;
135     if ((new_connection = accept(m_listening_socket, (SOCKADDR *)&client_addr, &client_addr_len))
136         == INVALID_SOCKET){
137         std::cout << "accept failed with error " << WSAGetLastError() << std::endl;
138     }
139     else{
140         std::cout << client_addr_len << std::endl;
141         SOCKADDR_IN client;
142         std::string str;
143         getpeername(new_connection, (sockaddr*)&client, &client_addr_len);
144         str = inet_ntoa(client.sin_addr);
145         std::cout << str << "   " << client.sin_port << std::endl;
146         std::cout << "accpet succesing!" << std::endl;
147     }
148     return new_connection;
149 }
150 
151 void TcpServer::loginPrompt(std::string v_user_name, SOCKET v_connection_socket)
152 { 
153     
154 //    std::cout << "before insert:" << m_client._My_val.size();
155     m_client._My_val.insert({ v_connection_socket, v_user_name });
156 //    std::cout << "after insert:" << m_client._My_val.size();
157     const std::string tip = makeTip(v_user_name);
158     sendData(tip);
159 }
160 
161 
162 std::string TcpServer::makeTip(const std::string& user_name)
163 {
164     std::string data = "User ";
165     data += user_name;
166     data += " login!";
167     return data;
168 }
169 
170 std::string TcpServer::recvData(SOCKET client)
171 {
172     std::string result;
173     const size_t array_len = 200;                              //用于存储信息
174     char buf[array_len];
175     int len = 0;
176     do{
177         len = recv(client, buf, sizeof(buf), 0);
178         if (len <= 0)
179         {
180             return "";
181         } 
182         else
183         {
184             buf[len] = \0;
185             result += buf;
186         }
187     } while (len >= sizeof(buf));
188     return result;
189 }
190 
191 bool TcpServer::sendData(std::string data)
192 {
193     if (data == "")
194         return false;
195     std::cout << "the count is " << m_client._My_val.size() << std::endl;
196     for (auto i : m_client._My_val){
197         if ((send(i.first, data.c_str(),
198             strlen(data.c_str()), 0)) == INVALID_SOCKET){
199             std::cout << "send data failed with error" << " " << WSAGetLastError() << std::endl;
200         }
201     //    else
202         //    std::cout << data<<std::endl;
203     }
204     return true;
205 }
206 
207 
208 void TcpServer::dealClient(std::string name,SOCKET client)
209 {
210     const std::string user=name+": ";
211     std::string message;
212     do{
213         message = user;
214         message += recvData(client);  //接收客户发送过来的信息
215         if (message != user)
216             sendData(message);
217         else{   //如果客户退出,则发送退出提示
218              closesocket(client);
219             m_client._My_val.erase(m_client._My_val.find(client));
220             const std::string exit_message = "user " + name + " exit!";
221             sendData(exit_message);
222         }
223     } while (message != user);
224 }
 1 #ifndef TCPS_H
 2 #define TCPS_H
 3 #include<WinSock2.h>
 4 #include<iostream>
 5 #include<string>
 6 #include<map>
 7 #include<thread>
 8 #include<atomic>
 9 #pragma comment(lib,"WS2_32.LIB")
10 class TcpServer{
11 private:
12     WSADATA wsa_data;          //在加载winsock DLL版本时被用来填充该库版本的有关信息
13     SOCKADDR_IN server_addr;       //本地(服务器)IPv4地址
14     const size_t  port = 9999;               //本地将要打开的端口  
15     SOCKET m_listening_socket;
16     std::atomic<std::map<SOCKET, std::string>> m_client;
17 public:
18     TcpServer();
19     virtual ~TcpServer()
20     {
21         std::cout << "调用了析构函数" << std::endl;
22         WSACleanup();
23         closesocket(m_listening_socket);    
24     }
25     void run();
26 private:
27     void initAddress();
28     void getReady();
29     void listenClient();
30     SOCKET connectionClient();
31     void loginPrompt(std::string v_user_name, SOCKET v_connection_socket);
32     std::string makeTip(const std::string& v_user_name);
33     std::string recvData(SOCKET v_client);
34     void dealClient(std::string name, SOCKET v_client);
35     bool sendData(std::string v_data);
36     
37 };
38 #endif

 代码估计不会难懂,我就不解释了吧。现在本人正在啃《unix网络编程卷一》《unix网络编程卷二》有同啃的人欢迎和我联系啊。

 最后说一点东西吧,我在大四时侥幸进入了一间游戏公司,在那里实习了三个月,最后被炒鱿鱼了。因为“眼高手低”。其实我心里对HR很不满,刚开始电话通知面试的时候很没有礼貌,后来一起面试的两个华师的跟我说HR对他们特别友善,公司距离他们学校直线距离不到200米竟然还跟他们详细说了怎么“拐弯”,我靠,对我却是不耐烦的脾气,好吧,我承认我学校确实只是普通本科,不是211的。但是最后只有我一个人通过技术面。而且HR工作后期说了一套做了一套,对此我极度不满,一天100块钱从早上九点上到晚上八点半,单双休轮流,能学到东西我也就算了,两个月后重复做任务,学不到啥东西,我就觉得特别不值,心情不好也就出了不少错,HR说让我滚蛋的时候我还特别高兴,我早就想走了,所以很痛快地饭都不吃直接走人了。不过说到底,确实有不少我的问题,主要是还是以学生态度跟同事沟通,造成矛盾,还有就是特别不爽工资和待遇,而且还学不到东西。刚开始能学到技术,我连续加了10多天班赶出产品都没有说什么。

 

大学生活阶段性总结

原文:http://www.cnblogs.com/yonghuiwei/p/5086519.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!