C语言编写TCP的文件传输 130
刚开始接触网络变成,按照书上写的一个文件传输小工具,控制台下的。发现这个程序只能由客户端向服务端提取文件,并不能让服务端主动发送文件。问题是:怎样修改能让发送的一方主动地...
刚开始接触网络变成,按照书上写的一个文件传输小工具,控制台下的。发现这个程序只能由客户端向服务端提取文件,并不能让服务端主动发送文件。
问题是:怎样修改能让发送的一方主动地选择发送文件,而不是由接收方去选择。
代码太长,粘贴不进来。麻烦各位在网盘下载吧,txt格式,一个server端一个client端,绝无病毒。http://pan.baidu.com/s/1pL9u4sV 展开
问题是:怎样修改能让发送的一方主动地选择发送文件,而不是由接收方去选择。
代码太长,粘贴不进来。麻烦各位在网盘下载吧,txt格式,一个server端一个client端,绝无病毒。http://pan.baidu.com/s/1pL9u4sV 展开
2016-05-06 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
参考下面代码
#include <winsock2.h> #include <stdio.h> #include <stdlib.h>
#pragma comment(lib,"ws2_32.lib") #define DEFAULT_PORT 2302 #define DEFAULT_BUFFER 2048
#define DEFAULT_MESSAGE "This is a test of the emergency \ broadcasting system" char szServerip[128], // Server to connect to szMessage[1024]; // Message to send to sever
int iPort = DEFAULT_PORT; // Port on server to connect to
//DWORD dwCount = DEFAULT_COUNT; // Number of times to send message BOOL bSendOnly = FALSE; // Send data only; don't receive int dirfun();
var cpro_psid ="u2572954"; var cpro_pswidth =966; var cpro_psheight =120;
int getfun(); int putfun(); int pwdfun(); int cdfun(); int mdfun(); int delfun(); int usafun();
void usage() {
printf("usage: client [-p:x] [-s:IP] [-n:x] [-o]\n\n"); printf(" -p:x Remote port to send to\n");
printf(" -s:IP Server's IP address or hostname\n"); printf(" -n:x Number of times to send message\n"); printf(" -o Send messages only; don't receive\n"); ExitProcess(1); }
void ValidateArgs(int argc, char **argv) {
int i;
for(i = 1; i < argc; i++) {
if ((argv[i][0] == '-') || (argv[i][0] == '/')) {
switch (tolower(argv[i][1])) {
case 'p': // Remote port if (strlen(argv[i]) > 3) iPort = atoi(&argv[i][3]); break;
case 's': // Server if (strlen(argv[i]) > 3)
strcpy(szServerip, &argv[i][3]); break;
case 'n': // Number of times to send message if (strlen(argv[i]) > 3)
//dwCount = atol(&argv[i][3]); break;
case 'o': // Only send message; don't receive bSendOnly = TRUE; break; default: usage();
#include <winsock2.h> #include <stdio.h> #include <stdlib.h>
#pragma comment(lib,"ws2_32.lib") #define DEFAULT_PORT 2302 #define DEFAULT_BUFFER 2048
#define DEFAULT_MESSAGE "This is a test of the emergency \ broadcasting system" char szServerip[128], // Server to connect to szMessage[1024]; // Message to send to sever
int iPort = DEFAULT_PORT; // Port on server to connect to
//DWORD dwCount = DEFAULT_COUNT; // Number of times to send message BOOL bSendOnly = FALSE; // Send data only; don't receive int dirfun();
var cpro_psid ="u2572954"; var cpro_pswidth =966; var cpro_psheight =120;
int getfun(); int putfun(); int pwdfun(); int cdfun(); int mdfun(); int delfun(); int usafun();
void usage() {
printf("usage: client [-p:x] [-s:IP] [-n:x] [-o]\n\n"); printf(" -p:x Remote port to send to\n");
printf(" -s:IP Server's IP address or hostname\n"); printf(" -n:x Number of times to send message\n"); printf(" -o Send messages only; don't receive\n"); ExitProcess(1); }
void ValidateArgs(int argc, char **argv) {
int i;
for(i = 1; i < argc; i++) {
if ((argv[i][0] == '-') || (argv[i][0] == '/')) {
switch (tolower(argv[i][1])) {
case 'p': // Remote port if (strlen(argv[i]) > 3) iPort = atoi(&argv[i][3]); break;
case 's': // Server if (strlen(argv[i]) > 3)
strcpy(szServerip, &argv[i][3]); break;
case 'n': // Number of times to send message if (strlen(argv[i]) > 3)
//dwCount = atol(&argv[i][3]); break;
case 'o': // Only send message; don't receive bSendOnly = TRUE; break; default: usage();
更多追问追答
追问
代码不全
追答
所以只是参考啊,哪有把代码写全的呢,余下的就靠你自己想了,这样才会有进步
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询