C/C++ code// Server.cpp : create a console application, and include the sources in the project
//
// 1. open the *.c in the Visual C++, then "rebuild all".
// 2. click "yes" to create a project workspace.
// 3. You need to -add the library 'ws2_32.lib' to your project
// (Project -> Properties -> Linker -> Input -> Additional Dependencies)
// 4. recompile the source.
#include "stdafx.h"
#include
#include
#include
#include
#include
#define DEFAULT_PORT 5019
int find(char s[],char t[]);
void accept_conn(void *dummy);
SOCKET sock,new_socket;
int main(int argc, char **argv){
int addr_len;
struct sockaddr_in local, client_addr;
WSADATA wsaData;
if (WSAStartup(0x202, &wsaData) == SOCKET_ERROR){
// stderr: standard error are printed to the screen.
fprintf(stderr, "WSAStartup failed with error %d\n", WSAGetLastError());
//WSACleanup function terminates use of the Windows Sockets DLL.
WSACleanup();
return -1;
}
// Fill in the address structure
local.sin_family = AF_INET;
local.sin_addr.s_addr = INADDR_ANY;
local.sin_port = htons(DEFAULT_PORT);
sock = socket(AF_INET,SOCK_STREAM, 0); //TCp socket
if (soc