C语言编写TCP的文件传输

C语言编写TCP的文件传输,第1张

参考下面代码

#include <winsock2.h>#include <stdio.h>#include <stdlib.h>

#pragma comment(lib,"ws2_32.lib") #define DEFAULT_PORT2302 #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 onlydon't receive int dirfun()

var cpro_psid ="u2572954"var cpro_pswidth =966var 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(" -oSend messages onlydon't receive\n")ExitProcess(1)}

void ValidateArgs(int argc, char **argv) {

inti

for(i = 1i <argci++) {

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 messagedon't receive bSendOnly = TRUEbreakdefault: usage()

是发送到什么地址的,如果是本机的,那就由于协议栈转发,不经过网卡,抓不到。

如果是发送给其他端的,但是你的wireshark没有在那个发送的网卡上监听,也抓不到的。

再检查一下吧。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11721395.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存