文件名称:网络文件传输程序
文件大小:8KB
文件格式:ARM
更新时间:2022-04-30 04:25:02
文件传输 tcpip
点对点文件传输,基于gcc,有简单的连接审核。 int main(int argc, char *argv[]) { int fd,new_fd,struct_len,numbytes,total_read=0; struct sockaddr_in server_addr; struct sockaddr_in client_addr; char buff[BUFSIZ]; char fname[255]; //用于存放文件名 FILE * fp; server_addr.sin_family = AF_INET; server_addr.sin_port = htons(8000); server_addr.sin_addr.s_addr = INADDR_ANY; bzero(&(server_addr.sin_zero), 8); struct_len = sizeof(struct sockaddr_in); fd = socket(AF_INET, SOCK_STREAM, 0); while(bind(fd, (struct sockaddr *)&server;_addr, struct_len) == -1); printf("Bind Success!\n"); while(listen(fd, 10) == -1); printf("Listening....\n");