Linux下文件的网络传输
今天的事太多,没有认真的完成任务,不过把服务器端的文件传输做好了!
明天把服务器端的代码集成起来测试一下,并把网络客户端程序做好!
把代码贴出来吧!便于保存!
头文件:server_udpsocket.h
#ifndef _SERVER_UDPSOCKET_H_
#define _SERVER_UDPSOCKET_H_
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <pthread.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define bool int
#define true 1
#define false 0
int errno ;
bool init_udpsocket() ;
bool udpsocket_Run() ;
void *thread_udpsocket() ;
#endif
程序文件:server_udpsocket.c
#include "server_udpsocket.h"
int hsockfd; // Socket file descriptor
int hnsockfd; // New Socket file descriptor
int localport=6767 ; //Local socket port
struct sockaddr_in addr_local; //local socket address
struct sockaddr_in addr_remote; //remote socket address
int sin_size ;
//file operation
FILE *file=NULL ;
char tempbuf[65535] ;
char revbuf[15] ;
//thread
pthread_t hthread_udpsocket ;
bool init_udpsocket()
{
int ret ;
//create socket file description
hsockfd=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) ;
if(hsockfd==-1)
{
printf("UDPSocket:failed to obtain socket descripter\n") ;
printf("Mesg:%s\n",sys_errlist[errno]) ;
return false ;
}
//fill local address
addr_local.sin_family = AF_INET; &nbs
相关文档:
转自http://blog.csdn.net/colorant/archive/2007/04/12/1561837.aspx
1 输入子系统架构Overview
输入子系统(Input Subsystem)的架构如下图所示
输入子系统由 输入子系统核心层( Input Core ),驱动层 ......
一、首先要准备必须的软件,我选用的版本如下:
apr-1.4.2,下载地址:http://archive.apache.org/dist/apr/
apr-util-1.3.9,下载地址:http://archive.apache.org/dist/apr/
apache(httpd-2.2.9),下载地址:http://archive.apache.org/dist/httpd/
SQLite-2.6.23.1,下载地址:http://www.sqlite.org/
neon- ......
Linux下配置静态IP地址,设置DNS和主机名
配置文件位于:
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.3
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
使
IP地址生效:
/sbin/ifdown eth0
/sbin/ifup eth0
主机名配置 /etc/sysconfig/network
NETWO ......
which 语法 which command 说明 依序从path环境变量所列的目录中找出command的位置,并显示完整路径的名称。在找到第一个符合条件的程序文件时,就立刻停止搜索,省略其余未搜索目录。 范例,找出ls命令的程序文件的位置: which ls 系统输出: /usr/bin/ls whereis 语法 whereis [option] name 说明 找出特定 ......