当前位置: 技术问答>linux和unix
为甚么linux tcp socket 文件传输总是出错呢???
来源: 互联网 发布时间:2017-01-15
本文导语: 每次./file_client都是这么错误 Usage: ././file_client ServerIPAddress 感谢大神指点一下??? int main(int argc, char **argv) { if (argc != 2) { printf("Usage: ./%s Server IP addressn",argv[0]); exit(1); ...
每次./file_client都是这么错误
Usage: ././file_client ServerIPAddress
感谢大神指点一下???
int main(int argc, char **argv)
{
if (argc != 2)
{
printf("Usage: ./%s Server IP addressn",argv[0]);
exit(1);
}
//time_t now;
FILE *stream;
//设置一个socket地址结构client_addr,代表客户机internet地址, 端口
struct sockaddr_in client_addr;
bzero(&client_addr,sizeof(client_addr)); //把一段内存区的内容全部设置为0
client_addr.sin_family = AF_INET; //internet协议族
client_addr.sin_addr.s_addr = htons(INADDR_ANY);//INADDR_ANY表示自动获取本机地址
client_addr.sin_port = htons(0); //0表示让系统自动分配一个空闲端口
//创建用于internet的流协议(TCP)socket,用client_socket代表客户机socket
int client_socket = socket(AF_INET,SOCK_STREAM,0);
if( client_socket
Usage: ././file_client ServerIPAddress
感谢大神指点一下???
int main(int argc, char **argv)
{
if (argc != 2)
{
printf("Usage: ./%s Server IP addressn",argv[0]);
exit(1);
}
//time_t now;
FILE *stream;
//设置一个socket地址结构client_addr,代表客户机internet地址, 端口
struct sockaddr_in client_addr;
bzero(&client_addr,sizeof(client_addr)); //把一段内存区的内容全部设置为0
client_addr.sin_family = AF_INET; //internet协议族
client_addr.sin_addr.s_addr = htons(INADDR_ANY);//INADDR_ANY表示自动获取本机地址
client_addr.sin_port = htons(0); //0表示让系统自动分配一个空闲端口
//创建用于internet的流协议(TCP)socket,用client_socket代表客户机socket
int client_socket = socket(AF_INET,SOCK_STREAM,0);
if( client_socket