c语言的tcp中的心跳程序,在线等,求C语言高手,实现一个简单的TCPIP程序以实现两台计算机之间的聊天通信,...

在线等,求C语言高手,实现一个简单的TCPIP程序以实现两台计算机之间的聊天通信,0

功能要求:

1)两个程序,分别是客户端和服务器端

2)可以在客户端或服务器端输入文本信息,回车后将文本信息传输到对端,文本显示在对端屏幕上。

3)服务器可以与一个或多个客户端连接

要求:

1)使用C或C++语言

2)利用TCP socket 实现

3)可以在windows 或 Linux/unix下调试

4)不做界面,直接用显示在console 窗口上

5)必须有足够的注释

老师给了结构// tcpsever.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include

#include

void _tmain(int argc, _TCHAR* argv[])

{

WSADATA wsaData;

int Port = 5150;

int Ret;

// Initialize Winsock version 2.2

if ((Ret = WSAStartup(MAKEWORD(2,2), &wsaData)) != 0)

{

// NOTE: Since Winsock failed to load we cannot use WSAGetLastError

// to determine the error code as is normally done when a Winsock

// API fails. We have to report the return status of the function.

printf("WSAStartup failed with error %d\n", Ret);

return;

}

WSACleanup();

}

// tcpsample.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include

#include

void _tmain(int argc, _TCHAR* argv[])

{

WSADATA wsaData;

int Ret;

// Initialize Winsock version 2.2

if ((Ret = WSAStartup(MAKEWORD(2,2), &wsaData)) != 0)

{

// NOTE: Since Winsock failed to load we cannot use WSAGetLastError

// to determine the error code as is normally done when a Winsock

// API fails. We have to report the return status of the function.

printf("WSAStartup failed with error %d\n", Ret);

return;

}

感激不尽啊

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值