- //#include "stdafx.h"
- //#include <winsock2.h>
- #include <string>
- #include <iostream>
- #include <fcntl.h>
- #include <sys/socket.h>
- #include <sys/types.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <netinet/in.h>
- #include <netdb.h>
- #include <stdio.h>
- #include <sys/stat.h>
- #include <pthread.h>
- #include <sys/io.h>
- //#include "io.h"
- #include <errno.h>
- //#include <conio.h>
- //#include <windows.h>
- #include <cstring>
- #include <arpa/inet.h>
- //#include <string>
- //#include <tchar.h>
- //#include <ws2tcpip.h>
- using namespace std;
- //#pragma comment(lib, "WS2_32") // WS2_32.lib
- int message_send_c();
- int message_send_s();
- int file_send_s();
- int file_send_c();
- int recv_c();
- int recv_s();
- int main_s();
- int main_c();
- int main_s6();
- int main_c6();
- int choose_s();
- int choose_c();
- int file_exists(char *file_name);
- int timer();
- int timer2();
- typedef int BOOL;
- typedef int SOCKET;
- BOOL
- _SocketRecv(
- SOCKET connectSocket,
- char *buf,
- int len
- );
- BOOL
- _SocketSend(
- SOCKET connectSocket,
- char *buf,
- int len
- );
- //#define BOOL int
- //#define true 1
- //#define false 0
- #define bytes 256
- #define f_size 1024
- #define f_Size 2048
- #define port_num "50001"
- #define ip_add "127.0.0.1"
- #define port_num6 "50001"
- #define ip_add6 "3002::3003"
- int sClient;
- int Csock;
- //HWND hWnd;
- double SUM = 0;
- double TOTAL = 0;
- int of_thread = 0;
- //using namespace std;
- struct Head
- {
- int head;
- int length;
- };
- struct message
- {
- Head head;
- char content[bytes];
- };
- struct file_check
- {
- int f_head;
- int total_length;
- char file_name[bytes];
- };
- struct file_content
- {
- int f_head;
- char file_contents[f_Size];
- };
- struct file1
- {
- Head head;
- file_check f_check;
- };
- struct file2
- {
- Head head;
- file_content f_content;
- };
- /*class CInitSock
- {
- //public:
- //CInitSock(BYTE minorVer = 2, BYTE majorVer = 2)
- {
- // 初始化WS2_32.dll
- //WSADATA wsaData;
- //WORD sockVersion = MAKEWORD(minorVer, majorVer);
- //if(::WSAStartup(sockVersion, &wsaData) != 0)
- {
- //exit(0);
- }
- //~CInitSock()
- {
- //::WSACleanup();
- }
- };*/
- //该片段来自于http://www.codesnippet.cn/detail/1010201513772.html
来源: http://www.codesnippet.cn/detail/1010201513772.html